IndexEdit.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-loading="loading"
  5. :show-close="false"
  6. :close-on-click-modal="false"
  7. :visible.sync="isShow"
  8. :title="curObj.id ? '编辑渠道' : '新增渠道'"
  9. :fullscreen="false"
  10. width="700px"
  11. custom-class="xl-dialog"
  12. center
  13. >
  14. <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px" :insertSlotArr="[9]">
  15. <div slot="OI9" class="scoped-other-form">
  16. <el-form-item label="点位坐标" class="scoped-item-two item">
  17. 纬度N<el-input v-model="cObj.latitude" disabled />
  18. 经度E<el-input v-model="cObj.longitude" disabled />
  19. <el-button type="primary" class="map-btn" size="small" @click="openMap">点击从地图获取</el-button>
  20. </el-form-item>
  21. </div>
  22. <div slot="footer" style="padding-top: 20px;">
  23. <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
  24. <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
  25. </div>
  26. </base-form>
  27. </el-dialog>
  28. <handle-map :is-show="isShowMap" @close="closeMap" />
  29. </div>
  30. </template>
  31. <script>
  32. import { arrToObj } from '@/utils'
  33. import handleMap from '@/components/Common/Map'
  34. export default {
  35. components: {
  36. handleMap,
  37. },
  38. mixins,
  39. props: {
  40. isShow: Boolean,
  41. curObj: Object
  42. },
  43. inject: ['parentData'],
  44. data() {
  45. const token = window.sessionStorage.getItem('fp_token')
  46. let domainUrl = process.env.VUE_APP_BASE_API
  47. return {
  48. domainUrl,
  49. token,
  50. loading: false,
  51. formData: [],
  52. cObj: {},
  53. isShowMap: false,
  54. }
  55. },
  56. watch: {
  57. isShow: function(val) {
  58. if (val) {
  59. if (this.curObj.id) {
  60. this.$api.shop.admstoredetail({id: this.curObj.id}).then(res => {
  61. this.cObj = res || {}
  62. this.getDef()
  63. })
  64. } else {
  65. this.cObj = this.curObj
  66. this.getDef()
  67. }
  68. }
  69. },
  70. },
  71. methods: {
  72. getDef (str, strKey, strParams) {
  73. let params = {...this.cObj}
  74. if (!params.sort) params.sort = '9'
  75. this.formData = [
  76. { label: '门店名称', key: 'store_name', class: 'c-2', rules: 1 },
  77. { label: '门店品牌', key: 'store_brand', class: 'c-2', type: 'select', class: 'c-2', options: this.$dictData.store_brand, rules: 1 },
  78. { label: '所属区域', key: 'area_type', type: 'select', class: 'c-2', options: this.$dictData.area_type, rules: 1 },
  79. { label: '店员数量', key: 'clerk_num', class: 'c-2', rules: 1 },
  80. { label: '店长', key: 'store_manager', class: 'c-2', rules: 1 },
  81. { label: '店长电话', key: 'manager_phone', class: 'c-2', rules: 1 },
  82. { label: '分销代码', key: 'dept_code', class: 'c-2' },
  83. { label: '排序', key: 'sort', class: 'c-2', rules: 1 },
  84. { label: '门店精英', key: 'store_elite' },
  85. { label: '地址', key: 'address', rules: 1 },
  86. { label: '门头照片', key: 'pri_image', class: 'c-2', type: 'cuImg',
  87. options: {
  88. w: 375,
  89. h: 250,
  90. }
  91. , rules: 1 },
  92. { label: '营业执照', key: 'busines_licens', type: 'upload', class: 'c-2'},
  93. ]
  94. this.setDefaultValue(params)
  95. },
  96. close (str) {
  97. if (str === 'confirm') {
  98. this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
  99. if (valid) {
  100. const oldform = this.$refs.ruleForm.baseForm
  101. const newForm = { ...oldform }
  102. newForm.longitude = this.cObj.longitude
  103. newForm.latitude = this.cObj.latitude
  104. if (!newForm.longitude) return this.$msgw('请选择经度!')
  105. else if (!newForm.latitude) return this.$msgw('请选择纬度!')
  106. let apiStr = 'admstoreadd'
  107. if (this.curObj.id) {
  108. newForm.id = this.curObj.id
  109. apiStr = 'admstoreedit'
  110. }
  111. this.$api.shop[apiStr](newForm).then(data => {
  112. this.$msgs(newForm.id ? '编辑成功' : '新增成功')
  113. this.productData = []
  114. this.$emit('close', newForm)
  115. })
  116. }
  117. })
  118. } else {
  119. this.$emit('close')
  120. this.productData = []
  121. this.setDefaultValue()
  122. }
  123. },
  124. openMap() { // 定位
  125. this.isShowMap = true
  126. const pointObj = {
  127. latitude: this.cObj.latitude || '',
  128. longitude: this.cObj.longitude || '',
  129. address: this.cObj.address || ''
  130. }
  131. this.$root.$emit('handleMap', pointObj)
  132. },
  133. closeMap(obj) {
  134. if (obj) {
  135. const oldform = this.$refs.ruleForm.baseForm
  136. const newForm = { ...oldform, ...obj }
  137. this.cObj = newForm
  138. this.setDefaultValue(newForm)
  139. }
  140. this.isShowMap = false
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. @import '../../../../styles/libEdit.scss';
  147. .lib-edit {
  148. width: 600px;
  149. padding-top: 0;
  150. padding-left: 0;
  151. padding-bottom: 40px;
  152. ::v-deep .el-form-item {
  153. margin-bottom: 10px;
  154. }
  155. ::v-deep .el-date-editor.el-input {
  156. width: 100%;
  157. }
  158. }
  159. .scoped-other-form {
  160. .scoped-item-two {
  161. .el-input {
  162. display: inline-block;
  163. width: 120px;
  164. margin: 0 10px;
  165. }
  166. }
  167. }
  168. .map-btn{
  169. height: 36px;
  170. }
  171. ::v-deep .el-drawer__header {
  172. margin-bottom: 10px;
  173. }
  174. ::v-deep .img-upload {
  175. width: 120px;
  176. height: 80px;
  177. .icon {
  178. width: 120px;
  179. height: 80px;
  180. line-height: 80px;
  181. }
  182. .img {
  183. width: 120px;
  184. height: 80px;
  185. }
  186. }
  187. </style>