瀏覽代碼

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
修改

1004749546@qq.com 4 年之前
父節點
當前提交
f72dde4a02

+ 33 - 2
src/api/boxSetting.js

@@ -1,11 +1,42 @@
 import { axios } from '@/utils/request'
 
 // 列表查询
-export const getList = (params) => {
-  const url = `advert/query/${params.pageNo}/${params.pageSize}`
+export const getBoxList = (params) => {
+  const url = `deviceType/query/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
   return axios({
     url: url,
     data: params,
     method: 'post'
   })
 }
+// 确认保存
+export const saveBoxSetting = (params) => {
+  const url = `deviceType/save`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+
+// 查详情
+export const viewBoxSetting = (params) => {
+  const url = `deviceType/findById/${params.id}`
+  return axios({
+    url: url,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 删除
+export const deleteBoxSetting = (params) => {
+  const url = `deviceType/delete/${params.id}`
+  return axios({
+    url: url,
+    data: {},
+    method: 'get'
+  })
+}

+ 13 - 105
src/views/equipmentManage/boxSetting/boxSetting.vue

@@ -42,6 +42,10 @@ import {
   VSelect
 } from '@/components'
 import AddBoxModal from './AddBoxModal.vue'
+import {
+  getBoxList,
+  deleteBoxSetting
+} from '@/api/boxSetting.js'
 export default {
   name: 'Equipment',
   components: {
@@ -145,111 +149,15 @@ export default {
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // return getTenantsList(Object.assign(parameter, this.queryParam)).then(res => {
-        //   if (res.status == 200) {
-        //     const no = (res.data.pageNo - 1) * res.data.pageSize
-        //     for (let i = 0; i < res.data.list.length; i++) {
-        //       const _item = res.data.list[i]
-        //       _item.no = no + i + 1
-        //       _item.status = _item.status + '' === '1'
-        //     }
-        //     return res.data
-        //   }
-        // })
-        return new Promise((resolve) => {
-          const data = [{
-            id: 1,
-            no: 1,
-            networkName: '网点1',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 2,
-            no: 2,
-            networkName: '网点2',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '晚高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 3,
-            no: 3,
-            networkName: '网点3',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 4,
-            no: 4,
-            networkName: '网点4',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 5,
-            no: 5,
-            networkName: '网点5',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 6,
-            no: 6,
-            networkName: '网点6',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
-          },
-          {
-            id: 7,
-            no: 7,
-            networkName: '网点7',
-            equipmentNo: '陕西省',
-            type: '西安市',
-            boxNum: '未央区',
-            address: '凤城十二路',
-            oProportion: '早高峰期',
-            tProportion: '23%',
-            edition: '1.2.1',
-            status: '1'
+        return getBoxList(Object.assign(parameter, this.queryParam)).then(res => {
+          if (res.status == 200) {
+            const no = (res.data.pageNo - 1) * res.data.pageSize
+            for (let i = 0; i < res.data.list.length; i++) {
+              const _item = res.data.list[i]
+              _item.no = no + i + 1
+            }
+            return res.data
           }
-          ]
-          resolve(data)
         })
       }
 
@@ -286,7 +194,7 @@ export default {
         okText: '确定',
         cancelText: '取消',
         onOk () {
-          delectRolePower({
+          deleteBoxSetting({
             id: row.id
           }).then(res => {
             console.log(res, 'res1111')

+ 18 - 2
src/views/equipmentManage/exchangeSetting/AddSetModal.vue

@@ -134,6 +134,13 @@ export default {
       default: function () {
         return ''
       }
+    },
+    // 兑换编码
+    goldExRuleNo: {
+      type: [String, Number],
+      default: function () {
+		  return ''
+      }
     }
   },
   data () {
@@ -185,13 +192,18 @@ export default {
         id: id
       }).then(res => {
         if (res.status == 200) {
-
+          this.formData = Object.assign({}, res.data)
+		  this.form.setFieldsValue({ 'formData.goldExRuleItemList': this.formData.goldExRuleItemList })
         }
       })
     },
     // 是否兑换切换
     handleStatusChange (item, index) {
       item.state = item.state ? 0 : 1
+	  this.form.getFieldDecorator('`formData.goldExRuleItemList[${index}].goleNum`', {
+	    initialValue: '',
+	    preserve: true
+	  })
       this.form.setFieldsValue({
         '`formData.goldExRuleItemList[${index}].goleNum`': ''
       })
@@ -212,6 +224,10 @@ export default {
             item.state = this.codeList[index].state
             item.rubbishType = this.codeList[index].code
           })
+		  if (this.id) {
+			  params.id = this.id
+			  params.goldExRuleNo = this.goldExRuleNo
+		  }
           saveExchangeSetting(params).then(res => {
             console.log(res, 'res--save')
             if (res.status + '' === '200') {
@@ -234,7 +250,6 @@ export default {
     clear () {
       this.form.resetFields()
       this.formData.name = ''
-      this.formData.isEnable = ''
       this.formData.remarks = ''
     }
 
@@ -255,6 +270,7 @@ export default {
       if (newValue) {
         if (this.id) { // 编辑
           this.titleText = '编辑'
+		  this.getDetailData(this.id)
         } else {
           this.titleText = '新增'
         }

+ 58 - 47
src/views/equipmentManage/exchangeSetting/ExchangeSetting.vue

@@ -5,12 +5,7 @@
         <a-row :gutter="48">
           <a-col :span="6">
             <a-form-item label="箱体类型" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-              <a-input
-                id="boxSetting-name"
-                allowClear
-                :maxLength="30"
-                v-model="queryParam.name"
-                placeholder="请输入箱体类型" />
+              <a-input id="boxSetting-name" allowClear :maxLength="30" v-model="queryParam.name" placeholder="请输入箱体类型" />
             </a-form-item>
           </a-col>
           <a-col :span="6">
@@ -33,16 +28,11 @@
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
         <a-icon type="edit" title="编辑" class="actionBtn icon-blues" @click="handleEdit(record)" />
-        <a-icon
-          type="delete"
-          title="删除"
-          class="actionBtn icon-red"
-          v-if="!record.isEnable"
-          @click="delect(record)" />
+        <a-icon type="delete" title="删除" class="actionBtn icon-red" v-if="!record.isEnable" @click="delect(record)" />
       </template>
     </s-table>
     <!-- 新增/编辑 弹窗 -->
-    <add-set-modal :visible="openBoxModal" :data="itemData" @refresh="refreshTable" @close="openBoxModal = false"></add-set-modal>
+    <add-set-modal :visible="openBoxModal" :goldExRuleNo="itemGoldExRuleNo" :id="itemId" @refresh="refreshTable" @close="openBoxModal = false"></add-set-modal>
   </a-card>
 </template>
 
@@ -52,7 +42,10 @@ import {
   VSelect
 } from '@/components'
 import AddSetModal from './AddSetModal.vue'
-import { getList, deleteExchangeSetting } from '@/api/exchangeSetting.js'
+import {
+  getList,
+  deleteExchangeSetting
+} from '@/api/exchangeSetting.js'
 export default {
   name: 'Equipment',
   components: {
@@ -75,8 +68,9 @@ export default {
       queryParam: {
         name: '' // 箱体类型
       },
-	  openBoxModal: false, // 新增/编辑弹窗
-	  boxId: '', //  箱体id
+      openBoxModal: false, // 新增/编辑弹窗
+      itemId: '', //  新增/编辑id
+	  itemGoldExRuleNo: '', // 兑换编码
       // 表头
       columns: [{
         title: '序号',
@@ -86,62 +80,68 @@ export default {
       },
       {
         title: '创建时间',
-        dataIndex: 'networkName',
+        dataIndex: 'createDate',
         width: 200,
         align: 'center'
       },
       {
         title: '兑换规则名称',
-        dataIndex: 'address',
+        dataIndex: 'name',
         width: 200,
         align: 'center'
       },
       {
         title: '兑换规则说明',
-        dataIndex: 'equipmentNo',
+        dataIndex: 'remarks',
         width: 200,
         align: 'center'
       },
       {
         title: '兑换规则(投放重量(g)/可兑换乐豆数(个))',
         children: [{
-          title: '废旧衣',
-          dataIndex: 'oProportion',
+          title: '废旧衣',
+          dataIndex: 'clothes',
           width: 100,
-          align: 'center'
+          align: 'center',
+          customRender: (record, text) => {
+            return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '--') : '--'
+          }
         },
         {
           title: '废旧塑料',
-          dataIndex: 'tProportion',
+          dataIndex: 'plastic',
           width: 100,
-          align: 'center'
+          align: 'center',
+          customRender: (record, text) => {
+            return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '--') : '--'
+          }
         },
         {
-		  title: '废旧金属',
-		  dataIndex: 'tProportion',
-		  width: 100,
-		  align: 'center',
-		  customRender: (record, index) => {
-			  return record.tProportion || '--'
-		  }
+          title: '废旧金属',
+          dataIndex: 'metal',
+          width: 100,
+          align: 'center',
+          customRender: (record, text) => {
+            return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '--') : '--'
+          }
         },
         {
-		  title: '废旧纸张',
-		  dataIndex: 'tProportion',
-		  width: 100,
-		  align: 'center',
-		  customRender: (record, index) => {
-			  return record.tProportion || '--'
-		  }
+          title: '废旧纸张',
+          dataIndex: 'paper',
+          width: 100,
+          align: 'center',
+          customRender: (record, text) => {
+            return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '--') : '--'
+          }
         },
         {
-		  title: '有害垃圾',
-		  dataIndex: 'tProportion',
-		  width: 100,
-		  align: 'center',
-		  customRender: (record, index) => {
-			  return record.tProportion || '--'
-		  }
+          title: '有害垃圾',
+          dataIndex: 'harm',
+          width: 100,
+          align: 'center',
+          customRender: (record, text) => {
+            return record ? (record.rubbishWeight ? (record.rubbishWeight + 'g/' + record.goleNum + '个') : '--') : '--'
+          }
         }
         ]
       },
@@ -182,14 +182,25 @@ export default {
       this.form.resetFields()
       this.$refs.table.refresh(true)
     },
+    // 新增/编辑 后刷新列表
+    refreshTable () {
+      if (this.itemId) {
+        this.$refs.table.refresh()
+      } else {
+        this.$refs.table.refresh(true)
+      }
+    },
     // 新建
     openModal () {
       this.openBoxModal = true
-      this.itemData = {}
+      this.itemId = ''
+	  this.itemGoldExRuleNo = ''
     },
     // 编辑
     handleEdit (item) {
-	  this.openBoxModal = true
+      this.openBoxModal = true
+      this.itemId = item.id
+	  this.itemGoldExRuleNo = item.goldExRuleNo
     },
     // 删除
     delect (row) {