| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <div>
- <el-dialog
- v-loading="loading"
- :show-close="false"
- :close-on-click-modal="false"
- :visible.sync="isShow"
- :title="curObj.id ? '编辑渠道' : '新增渠道'"
- :fullscreen="false"
- width="700px"
- custom-class="xl-dialog"
- center
- >
- <base-form ref="ruleForm" class="lib-edit" :data="formData" :is-inline="false" label-width="110px" :insertSlotArr="[9]">
- <div slot="OI9" class="scoped-other-form">
- <el-form-item label="点位坐标" class="scoped-item-two item">
- 纬度N<el-input v-model="cObj.latitude" disabled />
- 经度E<el-input v-model="cObj.longitude" disabled />
- <el-button type="primary" class="map-btn" size="small" @click="openMap">点击从地图获取</el-button>
- </el-form-item>
- </div>
- <div slot="footer" style="padding-top: 20px;">
- <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
- <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
- </div>
- </base-form>
- </el-dialog>
- <handle-map :is-show="isShowMap" @close="closeMap" />
- </div>
- </template>
- <script>
- import { arrToObj } from '@/utils'
- import handleMap from '@/components/Common/Map'
- export default {
- components: {
- handleMap,
- },
- mixins,
- props: {
- isShow: Boolean,
- curObj: Object
- },
- inject: ['parentData'],
- data() {
- const token = window.sessionStorage.getItem('fp_token')
- let domainUrl = process.env.VUE_APP_BASE_API
- return {
- domainUrl,
- token,
- loading: false,
- formData: [],
- cObj: {},
- isShowMap: false,
- }
- },
- watch: {
- isShow: function(val) {
- if (val) {
- if (this.curObj.id) {
- this.$api.shop.admstoredetail({id: this.curObj.id}).then(res => {
- this.cObj = res || {}
- this.getDef()
- })
- } else {
- this.cObj = this.curObj
- this.getDef()
- }
- }
- },
- },
- methods: {
- getDef (str, strKey, strParams) {
- let params = {...this.cObj}
- if (!params.sort) params.sort = '9'
- this.formData = [
- { label: '门店名称', key: 'store_name', class: 'c-2', rules: 1 },
- { label: '门店品牌', key: 'store_brand', class: 'c-2', type: 'select', class: 'c-2', options: this.$dictData.store_brand, rules: 1 },
- { label: '所属区域', key: 'area_type', type: 'select', class: 'c-2', options: this.$dictData.area_type, rules: 1 },
- { label: '店员数量', key: 'clerk_num', class: 'c-2', rules: 1 },
- { label: '店长', key: 'store_manager', class: 'c-2', rules: 1 },
- { label: '店长电话', key: 'manager_phone', class: 'c-2', rules: 1 },
- { label: '分销代码', key: 'dept_code', class: 'c-2' },
- { label: '排序', key: 'sort', class: 'c-2', rules: 1 },
- { label: '门店精英', key: 'store_elite' },
- { label: '地址', key: 'address', rules: 1 },
- { label: '门头照片', key: 'pri_image', class: 'c-2', type: 'cuImg',
- options: {
- w: 375,
- h: 250,
- }
- , rules: 1 },
- { label: '营业执照', key: 'busines_licens', type: 'upload', class: 'c-2'},
- ]
- this.setDefaultValue(params)
- },
- close (str) {
- if (str === 'confirm') {
- this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
- if (valid) {
- const oldform = this.$refs.ruleForm.baseForm
- const newForm = { ...oldform }
- newForm.longitude = this.cObj.longitude
- newForm.latitude = this.cObj.latitude
- if (!newForm.longitude) return this.$msgw('请选择经度!')
- else if (!newForm.latitude) return this.$msgw('请选择纬度!')
- let apiStr = 'admstoreadd'
- if (this.curObj.id) {
- newForm.id = this.curObj.id
- apiStr = 'admstoreedit'
- }
- this.$api.shop[apiStr](newForm).then(data => {
- this.$msgs(newForm.id ? '编辑成功' : '新增成功')
- this.productData = []
- this.$emit('close', newForm)
- })
- }
- })
- } else {
- this.$emit('close')
- this.productData = []
- this.setDefaultValue()
- }
- },
- openMap() { // 定位
- this.isShowMap = true
- const pointObj = {
- latitude: this.cObj.latitude || '',
- longitude: this.cObj.longitude || '',
- address: this.cObj.address || ''
- }
- this.$root.$emit('handleMap', pointObj)
- },
- closeMap(obj) {
- if (obj) {
- const oldform = this.$refs.ruleForm.baseForm
- const newForm = { ...oldform, ...obj }
- this.cObj = newForm
- this.setDefaultValue(newForm)
- }
- this.isShowMap = false
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '../../../../styles/libEdit.scss';
- .lib-edit {
- width: 600px;
- padding-top: 0;
- padding-left: 0;
- padding-bottom: 40px;
- ::v-deep .el-form-item {
- margin-bottom: 10px;
- }
- ::v-deep .el-date-editor.el-input {
- width: 100%;
- }
- }
- .scoped-other-form {
- .scoped-item-two {
- .el-input {
- display: inline-block;
- width: 120px;
- margin: 0 10px;
- }
- }
- }
- .map-btn{
- height: 36px;
- }
- ::v-deep .el-drawer__header {
- margin-bottom: 10px;
- }
- ::v-deep .img-upload {
- width: 120px;
- height: 80px;
- .icon {
- width: 120px;
- height: 80px;
- line-height: 80px;
- }
- .img {
- width: 120px;
- height: 80px;
- }
- }
- </style>
|