瀏覽代碼

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

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

+ 78 - 64
src/views/equipmentManage/exchangeSetting/AddSetModal.vue

@@ -31,79 +31,62 @@
             id="addSetModal-remarks"
             v-decorator="['formData.remarks', {
               initialValue: formData.remarks,getValueFromEvent: $filterEmpty,
-              rules: [{ required: true, message: '请输入规则说明(最多500个字符)!' }] }]" />
+              rules: [] }]" />
         </a-form-item>
         <!-- 箱体限投 -->
-        <a-row
-          type="flex"
-          align="middle"
-          v-for="(item, index) in keys"
-          :key="index">
+        <a-row type="flex" align="middle" v-for="(item, index) in codeList" :key="index">
           <a-col span="11">
             <!-- 请输入投放重量 -->
-            <a-form-item
-              :label="item.dispName"
-              :required="true"
-              :label-col=" { span: 11 }"
-              :wrapper-col=" { span: 13 }"
-            >
+            <a-form-item :label="item.dispName" :required="true" :label-col=" { span: 11 }" :wrapper-col=" { span: 13 }">
               <a-input-number
                 :min="1"
                 :max="999999"
-                :precision="2"
-                :disabled="!item.exchangeStatus"
+                :precision="0"
+                :disabled="!item.state"
                 style="width: 150px;"
                 placeholder="请输入投放重量(最大999999)"
                 v-decorator="[
-                  `formData.settings[${index}].weight`,
+                  `formData.goldExRuleItemList[${index}].rubbishWeight`,
                   {
                     validateTrigger: ['change', 'blur'],
                     rules: [
                       {
-                        required: true, message: '请输入投放重量(最大999999)!'
+                        required: item.state?true:false, message: '请输入投放重量(最大999999)!'
                       },
                     ],
                   },
-                ]"
-              />
+                ]" />
               <span>(g)</span>
             </a-form-item>
           </a-col>
           <a-col span="1"></a-col>
           <a-col span="8">
             <!-- 请输入可兑乐豆数 -->
-            <a-form-item
-              :label="''"
-              :required="false"
-              :wrapper-col="{ span: 18 }">
+            <a-form-item :label="''" :required="false" :wrapper-col="{ span: 18 }">
               <a-input-number
                 :min="1"
                 :max="999999"
                 :precision="0"
-                :disabled="!item.exchangeStatus"
+                :disabled="!item.state"
                 style="width: 140px;"
                 placeholder="请输入可兑乐豆数(最大999999)"
                 v-decorator="[
-                  `formData.settings[${index}].num`,
+                  `formData.goldExRuleItemList[${index}].goleNum`,
                   {
                     validateTrigger: ['change', 'blur'],
                     rules: [
                       {
-                        required: true, message: '请输入可兑乐豆数(最大999999)!'
+                        required: item.state?true:false, message: '请输入可兑乐豆数(最大999999)!'
                       },
                     ],
                   },
-                ]"
-              />
+                ]" />
               <span>(个)</span>
             </a-form-item>
           </a-col>
           <a-col span="3">
-            <a-form-item
-              :label="''"
-              :required="false"
-              :wrapper-col="{ span: 24 }">
-              <a-checkbox :checked="!item.exchangeStatus" @change="handleStatusChange(item,index)">
+            <a-form-item :label="''" :required="false" :wrapper-col="{ span: 24 }">
+              <a-checkbox :checked="!item.state" @change="handleStatusChange(item,index)">
                 不兑换
               </a-checkbox>
             </a-form-item>
@@ -128,8 +111,13 @@ import {
   STable,
   VSelect
 } from '@/components'
-import { viewExchangeSetting, saveExchangeSetting } from '@/api/exchangeSetting.js'
-import { listLookUp } from '@/api/data'
+import {
+  viewExchangeSetting,
+  saveExchangeSetting
+} from '@/api/exchangeSetting.js'
+import {
+  getLookUpData
+} from '@/api/data'
 export default {
   name: 'RoleModal',
   components: {
@@ -141,16 +129,15 @@ export default {
       type: Boolean,
       default: false
     },
-    data: {
-      type: Object,
+    id: {
+      type: [String, Number],
       default: function () {
-        return {}
+        return ''
       }
     }
   },
   data () {
     return {
-      id: 0,
       titleText: '新增',
       isshow: this.visible,
       formLayout: 'horizontal',
@@ -160,9 +147,9 @@ export default {
       formData: {
         name: '',
         remarks: '',
-        settings: []
+        goldExRuleItemList: []
       },
-      keys: []
+      codeList: []
     }
   },
   methods: {
@@ -170,28 +157,62 @@ export default {
       this.clear()
       this.$emit('close')
     },
+    // 查询分类数据字典
+    getTypeCode () {
+      getLookUpData({
+        pageNo: 1,
+        pageSize: 1000,
+        lookupCode: 'RUBBISH_TYPE'
+      }).then(res => {
+        const list = res.data.list
+        const arr = []
+        list.map(item => {
+          item.state = item.dispName == '有害垃圾' ? 0 : 1
+          const p = {
+            rubbishType: item.code,
+            rubbishWeight: '',
+            goleNum: ''
+          }
+          arr.push(p)
+        })
+        this.formData.goldExRuleItemList = arr
+        this.codeList = list
+      })
+    },
     // 查详情
     getDetailData (id) {
-	  viewExchangeSetting({ id: id }).then(res => {
-	    if (res.status == 200) {
+      viewExchangeSetting({
+        id: id
+      }).then(res => {
+        if (res.status == 200) {
 
-	    }
-	  })
+        }
+      })
     },
     // 是否兑换切换
     handleStatusChange (item, index) {
-      item.exchangeStatus = item.exchangeStatus ? 0 : 1
-	  this.form.setFieldsValue({ '`formData.settings[${index}].num`': '' })
-	  // this.formData.settings[index].num = ''
-	  // this.formData.settings[index].weight = ''
+      item.state = item.state ? 0 : 1
+      this.form.setFieldsValue({
+        '`formData.goldExRuleItemList[${index}].goleNum`': ''
+      })
+      this.form.resetFields(['`formData.goldExRuleItemList[${index}].goleNum`',
+        '`formData.goldExRuleItemList[${index}].rubbishWeight`'
+      ])
+      // this.formData.goldExRuleItemList[index].goleNum = ''
+      // this.formData.goldExRuleItemList[index].rubbishWeight = ''
     },
     // 保存提交
     handleSubmit () {
       const _this = this
       this.form.validateFields((err, values) => {
-		  console.log(values, ' formData.type222222222')
+        console.log(values, ' formData.type222222222')
         if (!err) {
-          saveExchangeSetting(Object.assign(this.formData, values.formData)).then(res => {
+          const params = values.formData
+          params.goldExRuleItemList.map((item, index) => {
+            item.state = this.codeList[index].state
+            item.rubbishType = this.codeList[index].code
+          })
+          saveExchangeSetting(params).then(res => {
             console.log(res, 'res--save')
             if (res.status + '' === '200') {
               this.$message.success(res.message ? res.message : '保存成功')
@@ -218,7 +239,9 @@ export default {
     }
 
   },
-  mounted () {},
+  mounted () {
+    this.getTypeCode()
+  },
   beforeCreate () {
     this.form = this.$form.createForm(this, {
       name: 'AddBoxModal'
@@ -230,19 +253,8 @@ export default {
     },
     isshow (newValue, oldValue) {
       if (newValue) {
-		  this.keys = [
-			  { dispName: '废旧衣物', code: 'fjyw', id: 11, exchangeStatus: 1 },
-			  { dispName: '废旧衣物', code: 'fjyw', id: 12, exchangeStatus: 1 },
-			  { dispName: '废旧衣物', code: 'fjyw', id: 13, exchangeStatus: 1 },
-			  { dispName: '废旧衣物', code: 'fjyw', id: 14, exchangeStatus: 1 },
-			  { dispName: '废旧衣物', code: 'fjyw', id: 15, exchangeStatus: 0 }
-		  ]
-        if (this.data.id) { // 编辑
+        if (this.id) { // 编辑
           this.titleText = '编辑'
-          this.formData = Object.assign({}, this.data)
-          delete this.formData.no
-          this.formData.isEnable = Number(this.formData.isEnable)
-          console.log(this.formData, 'this.formData')
         } else {
           this.titleText = '新增'
         }
@@ -260,10 +272,12 @@ export default {
 	.ant-modal-footer {
 		display: none;
 	}
+
 	.dynamic-delete-button {
 		margin-right: 20px;
 	}
-	.linenums{
+
+	.linenums {
 		padding: 0 20px;
 	}
 </style>

+ 0 - 95
src/views/equipmentManage/exchangeSetting/ExchangeSetting.vue

@@ -166,101 +166,6 @@ export default {
             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'
-      //     }
-      //     ]
-      //     resolve(data)
-      //   })
       }
 
     }