chenrui 4 роки тому
батько
коміт
ecc066bf48

+ 51 - 27
src/views/chainGroupManagement/chainGroupSetting/associateModal.vue

@@ -20,7 +20,9 @@
       :rowKey="(record) => record.id"
       :columns="columns"
       :dataSource="loadData"
-      :scroll="{ x: 910, y: 500 }"
+      :scroll="{ y: 500 }"
+      :pagination="false"
+      :loading="loading"
       bordered>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
@@ -33,13 +35,17 @@
           @click.stop="handleDisassociate(record)">取消关联</a-button>
       </template>
     </a-table>
+    <div class="btn-cont">
+      <a-button id="chainGroupAssociate-back" @click="isShow = false">取消</a-button>
+    </div>
     <!-- 新增关联分店 -->
-    <chain-group-store-modal :openModal="openStoreModal" :itemSn="itemSn" @close="openStoreModal=false" @ok="$refs.table.refresh(true)" />
+    <chain-group-store-modal :openModal="openStoreModal" :itemSn="itemSn" @close="openStoreModal=false" @ok="handlerOk" />
   </a-modal>
 </template>
 
 <script>
 import chainGroupStoreModal from './storeModal.vue'
+import { linkageGroupDetail, linkageGroupUnRelation } from '@/api/linkageGroup'
 export default {
   name: 'ChainGroupAssociateModal',
   components: { chainGroupStoreModal },
@@ -51,10 +57,6 @@ export default {
     itemSn: {
       type: [Number, String],
       default: ''
-    },
-    nowData: {
-      type: Object,
-      default: null
     }
   },
   data () {
@@ -69,32 +71,54 @@ export default {
       subDealerSn: '',
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '连锁分店名称', dataIndex: 'createDate', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '负责人', dataIndex: 'name', align: 'center', width: 220, customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '联系电话', dataIndex: 'code', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '邮箱', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
+        { title: '连锁分店名称', dataIndex: 'dealer.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '负责人', dataIndex: 'dealer.contactName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '联系电话', dataIndex: 'dealer.contactPhone', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 120, align: 'center', fixed: 'right' }
       ],
-      // // 加载数据方法 必须为 Promise 对象
-      // loadData: parameter => {
-      //   return productList(Object.assign(parameter, this.queryParam)).then(res => {
-      //     const data = res.data
-      //     const no = (data.pageNo - 1) * data.pageSize
-      //     for (var i = 0; i < data.list.length; i++) {
-      //       data.list[i].no = no + i + 1
-      //     }
-      //     this.disabled = false
-      //     return data
-      //   })
-      // },
       loadData: [],
-      openStoreModal: false
+      openStoreModal: false,
+      loading: false
     }
   },
   methods: {
     // 取消关联
-    handleDisassociate () {
-
+    handleDisassociate (row) {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '确认要解除关联关系吗?',
+        centered: true,
+        onOk () {
+          linkageGroupUnRelation({ sn: row.linkageGroupDetailSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('ok')
+              _this.getDetail()
+            }
+          })
+        }
+      })
+    },
+    // 关联成功
+    handlerOk () {
+      this.getDetail()
+      this.$emit('ok')
+    },
+    // 详情
+    getDetail () {
+      this.loading = true
+      linkageGroupDetail({ sn: this.itemSn }).then(res => {
+        this.loading = false
+        if (res.status == 200) {
+          res.data.map((item, index) => {
+            item.no = index + 1
+          })
+          this.loadData = res.data
+        } else {
+          this.loadData = []
+        }
+      })
     }
   },
   watch: {
@@ -107,7 +131,7 @@ export default {
       if (!newValue) {
         this.$emit('close')
       } else {
-        console.log(this.nowData, '-------------nowData')
+        this.getDetail()
       }
     }
   }

+ 4 - 1
src/views/chainGroupManagement/chainGroupSetting/editModal.vue

@@ -138,7 +138,10 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.$refs.ruleForm.resetFields()
+        this.form.linkageGroupName = ''
+        this.form.majorPersonName = ''
+        this.form.contactTel = ''
+        this.form.email = ''
       }
     },
     nowData: {

+ 39 - 21
src/views/chainGroupManagement/chainGroupSetting/list.vue

@@ -39,9 +39,27 @@
       :expandedRowKeys="expandedRowKeys"
       :expandRowByClick="true"
       :scroll="{ y: tableHeight }">
-      <span slot="expandIcon">
+      <!-- <span slot="expandIcon">
         1
-      </span>
+      </span> -->
+      <a-table
+        slot="expandedRowRender"
+        :rowKey="(record) => record.id"
+        :columns="innerColumns"
+        :data-source="innerData"
+        :pagination="false"
+      >
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record">
+          <a-button
+            type="link"
+            class="button-error"
+            size="small"
+            icon="close"
+            :id="'chainGroupSetList-delSubItem'+record.id"
+            @click.stop="handleDisassociate(record)">取消关联</a-button>
+        </template>
+      </a-table>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
         <a-button
@@ -58,17 +76,10 @@
           icon="edit"
           :id="'chainGroupSetList-addSubItem'+record.id"
           @click.stop="handleEdit(record)">编辑</a-button>
-        <a-button
-          type="link"
-          class="button-error"
-          size="small"
-          icon="close"
-          :id="'chainGroupSetList-delSubItem'+record.id"
-          @click.stop="handleDisassociate(record)">取消关联</a-button>
       </template>
     </a-table>
     <!-- 关联下级 -->
-    <associate-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="addItemOk" @close="closeModal" />
+    <associate-modal :openModal="openModal" :itemSn="itemSn" @ok="addItemOk" @close="closeModal" />
     <!-- 新增/编辑 -->
     <chain-group-edit-modal :openModal="openEditModal" :nowData="nowData" :itemId="itemId" @ok="getList" @close="closeEditModal" />
   </a-card>
@@ -94,7 +105,7 @@ export default {
       },
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
-        { title: '连锁组名称', dataIndex: 'linkageGroupName', align: 'left' },
+        { title: '连锁组名称', dataIndex: 'linkageGroupName', customRender: function (text) { return text || '--' }, ellipsis: true, align: 'left' },
         { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
       ],
       expandedRowKeys: [],
@@ -111,6 +122,13 @@ export default {
         showSizeChanger: true,
         pageSize: 10
       },
+      innerColumns: [
+        { title: '关联连锁店名称', dataIndex: 'dealer.name', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '负责人', dataIndex: 'dealer.contactName', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '联系电话', dataIndex: 'dealer.contactPhone', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
+      ],
+      innerData: [],
       openModal: false, //  新增编辑  弹框
       nowData: null, //  当前记录数据
       tabInd: '1', //  tabs选中项
@@ -141,21 +159,21 @@ export default {
     },
     // 获取子节点数据
     getSubItem (record) {
-      record.children = []
+      this.innerData = []
       linkageGroupDetail({ sn: record.linkageGroupSn }).then(res => {
         if (res.status == 200 && res.data && res.data.length) {
-          record.children = res.data
+          this.innerData = res.data
         } else {
-          record.children = this.nowData.children
+          this.innerData = []
         }
-        if (record.children.length == 0) {
+        if (res.data.length == 0) {
           this.$message.info('暂无分店,请关联分店')
         } else {
           this.expandedRowKeys = [record.linkageGroupSn]
         }
       })
     },
-    // 添加子成功
+    // 添加子成功
     addItemOk () {
       this.getSubItem(this.nowData)
     },
@@ -172,13 +190,11 @@ export default {
         const no = (data.pageNo - 1) * data.pageSize
         for (var i = 0; i < data.list.length; i++) {
           data.list[i].no = no + i + 1
-          data.list[i].children = []
         }
         this.disabled = false
         this.list = data.list
       })
     },
-    handleOk () {},
     // 关闭  新增编辑 弹框
     closeEditModal () {
       this.itemId = ''
@@ -188,7 +204,7 @@ export default {
     // 编辑连锁组
     handleEdit (row) {
       this.itemId = row.id
-      this.nowData = row
+      this.nowData = JSON.parse(JSON.stringify(row)) //  为避免编辑数据未改变无法触发表单赋值
       this.openEditModal = true
     },
     //  重置
@@ -204,20 +220,22 @@ export default {
     },
     // 关联下级
     handleAssociate (row) {
-      this.nowData = row
       this.itemSn = row.linkageGroupSn
+      this.nowData = row
+      this.getSubItem(this.nowData)
       this.expandedRowKeys = [row.linkageGroupSn]
       this.openModal = true
     },
     // 取消关联
     handleDisassociate (row) {
       const _this = this
+      _this.nowData = row
       _this.$confirm({
         title: '提示',
         content: '确认要解除关联的关系吗?',
         centered: true,
         onOk () {
-          linkageGroupUnRelation({ sn: row.linkageGroupSn }).then(res => {
+          linkageGroupUnRelation({ sn: row.linkageGroupDetailSn }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.addItemOk()

+ 2 - 3
src/views/chainGroupManagement/chainGroupSetting/storeModal.vue

@@ -32,7 +32,7 @@
 
 <script>
 import custList from '@/views/common/custList.vue'
-import { linkageGroupSave } from '@/api/linkageGroup'
+import { linkageGroupRelation } from '@/api/linkageGroup'
 export default {
   name: 'ChainGroupEditModal',
   components: { custList },
@@ -65,7 +65,6 @@ export default {
   },
   methods: {
     custChange (val) {
-      console.log('选中', val)
       this.form.dealerSn = val.key
     },
     //  保存
@@ -75,7 +74,7 @@ export default {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           form.linkageGroupSn = _this.itemSn
-          linkageGroupSave(form).then(res => {
+          linkageGroupRelation(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$emit('ok')