소스 검색

产品启用禁用

lilei 3 년 전
부모
커밋
24a56adf35
3개의 변경된 파일107개의 추가작업 그리고 45개의 파일을 삭제
  1. 8 0
      src/api/product.js
  2. 48 21
      src/views/productManagement/productInfo/list.vue
  3. 51 24
      src/views/productManagement/productInfoJg/list.vue

+ 8 - 0
src/api/product.js

@@ -11,6 +11,14 @@ export const productListPurchase = (params) => {
     method: 'post'
   })
 }
+// 经销商产品 更改状态
+export const productUpdate = params => {
+  return axios({
+    url: '/product/updateEnable',
+    data: params,
+    method: 'post'
+  })
+}
 //  箭冠 产品 列表  分页
 export const productList = (params) => {
   const url = `/product/queryPage/${params.pageNo}/${params.pageSize}`

+ 48 - 21
src/views/productManagement/productInfo/list.vue

@@ -68,9 +68,10 @@
         ref="table"
         :style="{ height: tableHeight + 84.5 + 'px' }"
         size="small"
-        :row-selection="{}"
+        :row-selection="rowSelection"
         @rowSelection="rowSelectionFun"
-        :rowKey="record => record.id"
+        rowKeyName="productSn"
+        :rowKey="(record) => record.productSn"
         :columns="columns"
         :data="loadData"
         :scroll="{ y: tableHeight }"
@@ -90,11 +91,13 @@
             id="productInfoList-enable"
             checkedChildren="启用"
             unCheckedChildren="禁用"
-            v-if="$hasPermissions('B_product_dealerProduct_enable')"
+            v-if="$hasPermissions('B_product_dealerProduct_enable')&&record.enabledFlag!=undefined"
             @change="changeStatus(record)"
             :checked="record.enabledFlag == 1 ? true : false"
           />
-          <span v-else :style="{ color: record.enabledFlag == 1 ? '#00aa00' : '#999' }">{{ record.enabledFlag == 1 ? '已启用' : '已禁用' }}</span>
+          <span v-else :style="{ color: record.enabledFlag == 1 ? '#00aa00' : '#999' }">
+            {{ record.enabledFlag == 1 ? '已启用' : (record.enabledFlag!=undefined?'已禁用':'--') }}
+          </span>
         </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="text, record">
@@ -267,20 +270,18 @@ export default {
       rowSelectionInfo: null
     }
   },
-  methods: {
-    // 表格选中项
-    rowSelectionFun (obj) {
-      this.rowSelectionInfo = obj || null
-    },
-    // 批量操作
-    handleOutbounds (type) {
-      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
-        this.$message.warning('请在列表勾选后再进行批量操作!')
+  computed: {
+    rowSelection () {
+      return {
+        getCheckboxProps: record => ({
+          props: {
+            disabled: record.enabledFlag == undefined // Column configuration not to be checked
+          }
+        })
       }
-    },
-    handleMenuClick (e) {
-      this.handleOutbounds(e.key)
-    },
+    }
+  },
+  methods: {
     //  重置
     resetSearchForm () {
       this.queryParam.code = ''
@@ -292,6 +293,8 @@ export default {
       this.queryParam.productTypeSn3 = ''
       this.queryParam.enabledFlag = undefined
       this.productType = []
+      this.$refs.table.clearSelected()
+      this.rowSelectionInfo = null
       this.$refs.table.refresh(true)
     },
     //  新增/编辑
@@ -332,20 +335,22 @@ export default {
         content: record.enabledFlag == '1' ? '产品被禁用后,不能再销售,确定禁用吗?' : '确定启用吗?',
         centered: true,
         onOk: () => {
-          this.setEnable(record)
+          this.setEnable(record.enabledFlag == 1 ? '0' : '1', [record.productSn])
         }
       })
     },
     // 启用 禁用
-    setEnable (record) {
+    setEnable (enabledFlag, snList) {
       const params = {
-        id: record.id,
-        enabledFlag: record.enabledFlag == 1 ? '0' : '1'
+        productSnList: snList,
+        enabledFlag: enabledFlag
       }
       this.spinning = true
       dealerProductUpdate(params).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
+          this.$refs.table.clearSelected()
+          this.rowSelectionInfo = null
           this.$refs.table.refresh()
           this.spinning = false
         } else {
@@ -354,6 +359,28 @@ export default {
         }
       })
     },
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 批量操作
+    handleOutbounds (type) {
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 0)) {
+        this.$message.warning('请在列表勾选后再进行批量操作!')
+        return
+      }
+      this.$confirm({
+        title: '提示',
+        content: type == '2' ? '产品被禁用后,不能再销售,确定批量禁用吗?' : '确定批量启用吗?',
+        centered: true,
+        onOk: () => {
+          this.setEnable(type == '2' ? '0' : '1', this.rowSelectionInfo.selectedRowKeys)
+        }
+      })
+    },
+    handleMenuClick (e) {
+      this.handleOutbounds(e.key)
+    },
     //  导出
     handleExport () {
       this.exportLoading = true

+ 51 - 24
src/views/productManagement/productInfoJg/list.vue

@@ -65,9 +65,10 @@
       ref="table"
       :style="{ height: tableHeight+84.5+'px' }"
       size="small"
-      :row-selection="{}"
+      :row-selection="rowSelection"
       @rowSelection="rowSelectionFun"
-      :rowKey="(record) => record.id"
+      rowKeyName="productSn"
+      :rowKey="(record) => record.productSn"
       :columns="columns"
       :data="loadData"
       :scroll="{ y: tableHeight }"
@@ -90,11 +91,13 @@
         <a-switch
           checkedChildren="启用"
           unCheckedChildren="禁用"
-          v-if="$hasPermissions('B_JgProduct_enable')"
+          v-if="$hasPermissions('B_JgProduct_enable')&&record.enabledFlag!=undefined"
           @change="changeStatus(record)"
           :checked="record.enabledFlag == 1 ? true : false"
         />
-        <span v-else :style="{ color: record.enabledFlag == 1 ? '#00aa00' : '#999' }">{{ record.enabledFlag == 1 ? '已启用' : '已禁用' }}</span>
+        <span v-else :style="{ color: record.enabledFlag == 1 ? '#00aa00' : '#999' }">
+          {{ record.enabledFlag == 1 ? '已启用' : (record.enabledFlag!=undefined?'已禁用':'--') }}
+        </span>
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
@@ -111,7 +114,7 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { productList, getCurrentDealer, dealerProductUpdate } from '@/api/product'
+import { productList, getCurrentDealer, productUpdate } from '@/api/product'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 import { STable, VSelect } from '@/components'
@@ -164,20 +167,18 @@ export default {
       rowSelectionInfo: null
     }
   },
-  methods: {
-    // 表格选中项
-    rowSelectionFun (obj) {
-      this.rowSelectionInfo = obj || null
-    },
-    // 批量操作
-    handleOutbounds (type) {
-      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
-        this.$message.warning('请在列表勾选后再进行批量操作!')
+  computed: {
+    rowSelection () {
+      return {
+        getCheckboxProps: record => ({
+          props: {
+            disabled: record.enabledFlag == undefined // Column configuration not to be checked
+          }
+        })
       }
-    },
-    handleMenuClick (e) {
-      this.handleOutbounds(e.key)
-    },
+    }
+  },
+  methods: {
     inited (viewer) {
       if (viewer) {
         const imageUrl = []
@@ -202,9 +203,11 @@ export default {
       this.queryParam.productTypeSn1 = ''
       this.queryParam.productTypeSn2 = ''
       this.queryParam.productTypeSn3 = ''
-      this.queryParam.onlineFalg = '1'
+      this.queryParam.onlineFalg = ''
       this.productType = []
       this.$refs.table.refresh(true)
+      this.rowSelectionInfo = null
+      this.$refs.table.clearSelected()
     },
     // 设置表头
     getColumns () {
@@ -258,20 +261,22 @@ export default {
         content: record.enabledFlag == '1' ? '产品被禁用后,不能再销售,确定禁用吗?' : '确定启用吗?',
         centered: true,
         onOk: () => {
-          this.setEnable(record)
+          this.setEnable(record.enabledFlag == 1 ? '0' : '1', [record.productSn])
         }
       })
     },
     // 启用 禁用
-    setEnable (record) {
+    setEnable (enabledFlag, snList) {
       const params = {
-        id: record.id,
-        enabledFlag: record.enabledFlag == 1 ? '0' : '1'
+        productSnList: snList,
+        enabledFlag: enabledFlag
       }
       this.spinning = true
-      dealerProductUpdate(params).then(res => {
+      productUpdate(params).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
+          this.$refs.table.clearSelected()
+          this.rowSelectionInfo = null
           this.$refs.table.refresh()
           this.spinning = false
         } else {
@@ -280,6 +285,28 @@ export default {
         }
       })
     },
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 批量操作
+    handleOutbounds (type) {
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 0)) {
+        this.$message.warning('请在列表勾选后再进行批量操作!')
+        return
+      }
+      this.$confirm({
+        title: '提示',
+        content: type == '2' ? '产品被禁用后,不能再销售,确定批量禁用吗?' : '确定批量启用吗?',
+        centered: true,
+        onOk: () => {
+          this.setEnable(type == '2' ? '0' : '1', this.rowSelectionInfo.selectedRowKeys)
+        }
+      })
+    },
+    handleMenuClick (e) {
+      this.handleOutbounds(e.key)
+    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调