Sfoglia il codice sorgente

fix:修复上传组件和水权计算问题

zhb 8 mesi fa
parent
commit
9a8f0488cd

+ 9 - 4
src/components/ImageUpload/index.vue

@@ -113,7 +113,8 @@ export default {
     title: {
       type: Boolean,
       default: true
-    }
+    },
+    VUE_APP_BASE_API: { type: String, default: process.env.VUE_APP_BASE_API }
   },
   data() {
     return {
@@ -176,7 +177,11 @@ export default {
   },
   computed: {
     uploadImgUrl() {
-      return process.env.VUE_APP_BASE_API + UPDALOD_API_MAP[this.uploadType];
+      if (UPDALOD_API_MAP[this.uploadType].includes('prod-api')) {
+        return UPDALOD_API_MAP[this.uploadType];
+      } else {
+        return this.VUE_APP_BASE_API + UPDALOD_API_MAP[this.uploadType];
+      }
     },
     // 是否显示提示
     showTip() {
@@ -247,12 +252,12 @@ export default {
     },
     // 上传成功回调
     handleUploadSuccess(res, file, fileList) {
-      const { resUrl, url, resId, resCreatorname, resOssUrl } = res.data;
       if (res.code === '000000') {
+        const { resUrl, url, resId, resCreatorname, resOssUrl } = res.data;
         this.uploadList.push({
           resId: resId,
           name: url || resCreatorname,
-          url: resOssUrl || resUrl
+          url: resOssUrl || resUrl || url
         });
 
         this.uploadedSuccessfully();

+ 4 - 2
src/utils/constants.js

@@ -44,7 +44,8 @@ export const UPLOAD_TYPE_MAP = {
   SYINFO_PERIOD: 'SYINFO_PERIOD',
   SYINFO_FIGURE: 'SYINFO_FIGURE',
   PACKAGE: 'PACKAGE',
-  QUALITYCHECK: 'QUALITYCHECK'
+  QUALITYCHECK: 'QUALITYCHECK',
+  POLICY: 'POLICY'
 };
 
 // 上传API
@@ -78,7 +79,8 @@ export const UPDALOD_API_MAP = {
   [UPLOAD_TYPE_MAP['SYINFO_PERIOD']]: '/tss/sourceinfo/period/upload', // 溯源-溯源信息 生长过程 figure
   [UPLOAD_TYPE_MAP['SYINFO_FIGURE']]: '/tss/sourceinfo/figure/upload', // 溯源-溯源信息 形象 figure
   [UPLOAD_TYPE_MAP['PACKAGE']]: '/wms/finishgoods/period/upload', // 包装-包装过程图片
-  [UPLOAD_TYPE_MAP['QUALITYCHECK']]: '/mpp/qualitycheck/upload' // 质检图片上传
+  [UPLOAD_TYPE_MAP['QUALITYCHECK']]: '/mpp/qualitycheck/upload', // 质检图片上传
+  [UPLOAD_TYPE_MAP['POLICY']]: '/wpr/subsidypolicy/preview/upload' // 政策法规图片
 };
 
 // 农事审核类型

+ 93 - 59
src/views/infrastructure/components/recompose.vue

@@ -21,7 +21,7 @@
           <el-input
             placeholder="请输入"
             disabled
-            style="width:250px;"
+            style="width: 250px"
             v-model="editRow.waterrightYear"
           />
         </el-form-item>
@@ -31,14 +31,22 @@
           <el-input
             placeholder="请输入"
             disabled
-            style="width:250px;"
-            v-model="editRow.cusareaName">
+            style="width: 250px"
+            v-model="editRow.cusareaName"
+          >
           </el-input>
         </el-form-item>
       </el-row>
       <el-row v-if="cusareaParentid != 0">
         <el-form-item label="">
-          <span>(上级组织:{{ infoData.cusareaName }} 总面积:{{ infoData.areasizeResidue || 0 }} 亩 额定水权:{{ infoData.waterrightAmount || 0 }} m³ 剩余水权:{{ infoData.amountResidue || 0 }})</span>
+          <span
+            >(上级组织:{{ infoData.cusareaName }} 总面积:{{
+              infoData.areasizeResidue || 0
+            }}
+            亩 额定水权:{{ infoData.waterrightAmount || 0 }} m³ 剩余水权:{{
+              infoData.amountResidue || 0
+            }})</span
+          >
         </el-form-item>
       </el-row>
       <el-row>
@@ -49,10 +57,10 @@
             @input="areasizeResidueHandler"
             :max="Number(infoData.areasizeResidue || 0)"
             v-model="baseForm.area"
-            style="width:250px;"
+            style="width: 250px"
           >
           </el-input>
-          <span style="margin-left:5px">亩</span>
+          <span style="margin-left: 5px">亩</span>
         </el-form-item>
       </el-row>
       <el-row>
@@ -60,12 +68,13 @@
           <el-input
             type="number"
             placeholder="请输入"
-            style="width:250px;"
+            style="width: 250px"
             @input="waterrightAmountHandler"
             :max="Number(infoData.waterrightAmount || 0)"
-            v-model="baseForm.ratedWater">
+            v-model="baseForm.ratedWater"
+          >
           </el-input>
-          <span style="margin-left:5px">m³ </span>
+          <span style="margin-left: 5px">m³ </span>
         </el-form-item>
       </el-row>
       <el-row>
@@ -77,21 +86,23 @@
         <el-form-item label="亩均水权:">
           <el-input
             placeholder="请输入"
-            style="width:250px;"
+            style="width: 250px"
             disabled
-            v-model="averageWater">
+            v-model="averageWater"
+          >
           </el-input>
-          <span style="margin-left:5px">亩/m³</span>
+          <span style="margin-left: 5px">m³/亩</span>
         </el-form-item>
       </el-row>
     </el-form>
 
     <div style="text-align: right">
-      <el-button type="info" plain @click="resetForm('baseForm')">取消</el-button
+      <el-button type="info" plain @click="resetForm('baseForm')"
+        >取消</el-button
       >
       <el-button
         type="primary"
-        style="margin-left:16px;"
+        style="margin-left: 16px"
         @click="submitForm('baseForm')"
         :disabled="dialogSubmitLoading"
         :loading="dialogSubmitLoading"
@@ -103,7 +114,10 @@
 
 <script>
 import { assign } from 'lodash-es';
-import { getWaterrightUpareaInfo, editWaterright } from '@/api/waterright/index.js'
+import {
+  getWaterrightUpareaInfo,
+  editWaterright
+} from '@/api/waterright/index.js';
 
 export default {
   name: 'recompose',
@@ -119,7 +133,7 @@ export default {
     },
     editRow: {
       type: Object,
-      default:() => {}
+      default: () => {}
     }
   },
   data() {
@@ -138,26 +152,45 @@ export default {
       rules: {
         area: [
           {
-            required: true, validator: (rule, value, callback) => {
-              if (!+value) { callback(new Error('请输入面积')); return }
-              if (isNaN(value)) callback(new Error('请正确输入您的面积'))
-              else if (value > this.infoData.areasizeResidue && this.cusareaParentid != 0) {
-                callback(new Error('输入的面积不能大于总面积'))
+            required: true,
+            validator: (rule, value, callback) => {
+              if (!+value) {
+                callback(new Error('请输入面积'));
+                return;
+              }
+              if (isNaN(value)) callback(new Error('请正确输入您的面积'));
+              else if (
+                value > this.infoData.areasizeResidue &&
+                this.cusareaParentid != 0
+              ) {
+                callback(new Error('输入的面积不能大于总面积'));
               } else {
-                callback()
+                callback();
               }
-            }, trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ],
         ratedWater: [
-          { required: true, validator: (rule, value, callback) => {
-            if (!+value) {  callback(new Error('请输入额定水权'));  return}
-            if(isNaN(value)) callback(new Error('请正确输入您的额定水权'))
-            else if (value > this.infoData.waterrightAmount && this.cusareaParentid != 0) {
-              callback(new Error('输入的额定水权不能大于总额定水权'))
-            } else { 
-              callback()
-            }
-          },  trigger: 'blur' }
+          {
+            required: true,
+            validator: (rule, value, callback) => {
+              if (!+value) {
+                callback(new Error('请输入额定水权'));
+                return;
+              }
+              if (isNaN(value)) callback(new Error('请正确输入您的额定水权'));
+              else if (
+                value > this.infoData.waterrightAmount &&
+                this.cusareaParentid != 0
+              ) {
+                callback(new Error('输入的额定水权不能大于总额定水权'));
+              } else {
+                callback();
+              }
+            },
+            trigger: 'blur'
+          }
         ]
       }
     };
@@ -174,25 +207,25 @@ export default {
         }
       }
     },
-    editRow:{
+    editRow: {
       handler(val) {
-        const { cusareaParentid } = val
-        this.cusareaParentid = cusareaParentid
-        this.visible && this.getWaterrightUpareaList(val)
+        const { cusareaParentid } = val;
+        this.cusareaParentid = cusareaParentid;
+        this.visible && this.getWaterrightUpareaList(val);
       },
       deep: true
     },
     baseForm: {
-      handler(val) { 
-        const { area, ratedWater } = val
+      handler(val) {
+        const { area, ratedWater } = val;
         if (area && ratedWater) {
-          this.averageWater = !+area ? 0 : (+ratedWater / +area).toFixed(2)
-        } else { 
-          this.averageWater = 0
+          this.averageWater = !+area ? 0 : (+ratedWater / +area).toFixed(2);
+        } else {
+          this.averageWater = 0;
         }
       },
       deep: true
-     }
+    }
   },
   methods: {
     areasizeResidueHandler(v) {
@@ -202,43 +235,44 @@ export default {
       this.baseForm.ratedWater = v.replace(/^(\d*\.?\d{0,2}).*/, '$1');
     },
     async getWaterrightUpareaList(row) {
-      const { waterrightId } = row
+      const { waterrightId } = row;
       const res = await getWaterrightUpareaInfo({
         waterrightId
-      })
-      this.infoData = res?.data
+      });
+      this.infoData = res?.data;
     },
     resetForm() {
-      this.dialogVisible = false; 
+      this.dialogVisible = false;
       this.baseForm = {
         area: '',
-        ratedWater: '',
-      }
-      this.averageWater = 0
+        ratedWater: ''
+      };
+      this.averageWater = 0;
     },
-    async editRecompose() { 
-      const { waterrightId } = this.editRow
-      const { area: waterrightAreasize, ratedWater: waterrightAmount } = this.baseForm
+    async editRecompose() {
+      const { waterrightId } = this.editRow;
+      const { area: waterrightAreasize, ratedWater: waterrightAmount } =
+        this.baseForm;
       const params = {
         waterrightId,
         waterrightAreasize,
         waterrightAmount
-      }
-      const res = await editWaterright(params)
-      this.handleClose()
-      this.$emit('refresh')
+      };
+      const res = await editWaterright(params);
+      this.handleClose();
+      this.$emit('refresh');
     },
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
-        valid && this.editRecompose(formName)
-      })
+        valid && this.editRecompose(formName);
+      });
     },
 
     handleClose() {
       this.$emit('update:visible', false);
       this.$emit('resetEdit');
       this.resetForm();
-    },
+    }
   }
 };
 </script>

+ 188 - 143
src/views/peasantHouseholdManage/components/addedFarmers.vue

@@ -17,13 +17,16 @@
       size="small"
     >
       <el-row>
-        <el-col :span="24" style="background:#F5F7FA;padding-top:20px;margin-bottom:20px;">
+        <el-col
+          :span="24"
+          style="background: #f5f7fa; padding-top: 20px; margin-bottom: 20px"
+        >
           <el-form-item label="所属区域" prop="areaId">
             <el-row>
-              <el-col :span="24" style="padding-right:5%">
-                <select-tree 
-                  :placeholder="'请选择区域'" 
-                  style="width:100%"
+              <el-col :span="24" style="padding-right: 5%">
+                <select-tree
+                  :placeholder="'请选择区域'"
+                  style="width: 100%"
                   :treeData="treeData"
                   @handlerClick="handlerClick"
                   :checkVal="cusareaName"
@@ -33,17 +36,11 @@
           </el-form-item>
           <el-col>
             <el-row class="area">
+              <el-col> <label>总面积:</label>{{ areaAll }}亩 </el-col>
+              <el-col> <label>总水权:</label>{{ waterRightAll }}m³ </el-col>
+              <el-col> <label>亩产水权:</label>{{ yieldPer }} m³/亩 </el-col>
               <el-col>
-                  <label>总面积:</label>{{ areaAll }}亩
-              </el-col>
-              <el-col>
-                <label>总水权:</label>{{ waterRightAll }}m³
-              </el-col>
-              <el-col>
-                  <label>亩产水权:</label>{{ yieldPer }}亩/m³
-              </el-col>
-              <el-col>
-                  <label>剩余水权:</label>{{ residualWaterRight }}m³
+                <label>剩余水权:</label>{{ residualWaterRight }}m³
               </el-col>
             </el-row>
           </el-col>
@@ -102,23 +99,25 @@
                 </el-row>
               </el-form-item>
             </el-col>
-              <el-col :span="12">
-                <el-form-item label="土地面积" prop="farmerAreasize">
-                  <el-row>
-                    <el-col style="position:relative">
-                      <el-input
-                        v-model="baseForm.farmerAreasize"
-                        type="number"
-                        filterable
-                        style="width: 90%"
-                        placeholder="请输入土地面积"
-                      >
-                      </el-input>
-                      <span style="position:absolute;margin-left:10px">亩</span>
-                    </el-col>
-                  </el-row>
-                </el-form-item>
-              </el-col>
+            <el-col :span="12">
+              <el-form-item label="土地面积" prop="farmerAreasize">
+                <el-row>
+                  <el-col style="position: relative">
+                    <el-input
+                      v-model="baseForm.farmerAreasize"
+                      type="number"
+                      filterable
+                      style="width: 90%"
+                      placeholder="请输入土地面积"
+                    >
+                    </el-input>
+                    <span style="position: absolute; margin-left: 10px"
+                      >亩</span
+                    >
+                  </el-col>
+                </el-row>
+              </el-form-item>
+            </el-col>
           </el-row>
         </el-col>
         <el-col :span="24">
@@ -149,7 +148,7 @@
       >
       <el-button
         type="primary"
-        style="margin-left:16px;"
+        style="margin-left: 16px"
         @click="submitForm('baseForm')"
         :disabled="dialogSubmitLoading"
         :loading="dialogSubmitLoading"
@@ -160,14 +159,14 @@
 </template>
 
 <script>
-import { Message } from 'element-ui'
-import { isValidIDCard, checkPhone } from '@/utils/index.js'
+import { Message } from 'element-ui';
+import { isValidIDCard, checkPhone } from '@/utils/index.js';
 import SelectTree from '@/components/SelectTree';
-import { addFarmer,editFarmer, getAreaInfo } from '@/api/farmer/list.js'
+import { addFarmer, editFarmer, getAreaInfo } from '@/api/farmer/list.js';
 
 export default {
   name: 'addedFarmers',
-  components:{
+  components: {
     SelectTree
   },
   props: {
@@ -183,7 +182,7 @@ export default {
       type: Object,
       default: () => {}
     },
-    isEdit:{
+    isEdit: {
       type: Boolean,
       default: false
     },
@@ -214,74 +213,114 @@ export default {
         ],
         farmerIdcard: [
           {
-            required: true, validator: (rule, value, callback) => {
+            required: true,
+            validator: (rule, value, callback) => {
               if (!value) callback(new Error('请输入农户身份证号'));
-              const vaild = isValidIDCard(value)
+              const vaild = isValidIDCard(value);
               if (vaild) {
-                callback()
-              } else { 
+                callback();
+              } else {
                 callback(new Error('请正确输入农户身份证号'));
               }
-            
-          }, trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ],
         farmerPhone: [
-          { required: true, validator: (rule, value, callback) => {
+          {
+            required: true,
+            validator: (rule, value, callback) => {
               if (!value) callback(new Error('请输入联系电话'));
-              const vaild = checkPhone(value)
+              const vaild = checkPhone(value);
               if (vaild) {
-                callback()
+                callback();
               } else {
                 callback(new Error('请正确输入联系电话'));
               }
-
-            },  trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ],
         farmerAreasize: [
           {
-            required: true, validator: (rule, value, callback) => {
-              if (!value) { callback(new Error('请输入土地面积')); return }
-              if (+value < 0) {  callback(new Error('土地面积不能为负数')); return }
-              if (isNaN(value)) { callback(new Error('请正确输入您的土地面积')); return }
+            required: true,
+            validator: (rule, value, callback) => {
+              console.log(
+                value,
+                this.areasizeResidue,
+                '------------------- farmer area size'
+              );
+              if (!value) {
+                callback(new Error('请输入土地面积'));
+                return;
+              }
+              if (+value < 0) {
+                callback(new Error('土地面积不能为负数'));
+                return;
+              }
+              if (isNaN(value)) {
+                callback(new Error('请正确输入您的土地面积'));
+                return;
+              }
               if (this.isEdit) {
-                if (+value > (+this.areasizeResidue) + (+this.editFarmerData.farmerAreasize)) {
-                  callback(new Error('输入的土地面积不能大于总面积'))
-                  return
+                if (
+                  +value >
+                  +this.areasizeResidue + +this.editFarmerData.farmerAreasize
+                ) {
+                  callback(new Error('输入的土地面积不能大于总面积'));
+                  return;
                 } else {
-                  callback()
+                  callback();
                 }
               } else {
                 if (+value > +this.areasizeResidue) {
-                  callback(new Error('输入的水权不能大于剩余面积'))
-                  return
+                  callback(new Error('输入的水权不能大于剩余面积'));
+                  return;
                 } else {
-                  callback()
+                  callback();
                 }
               }
-            }, trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ],
         farmerWramount: [
           {
-            required: true, validator: (rule, value, callback) => {
-              if (value == 0) { callback(new Error('请输入水权')); return }
-              if (+value < 0) { callback(new Error('水权不能为负数')); return }
-              if (isNaN(value)) { callback(new Error('请正确输入您的水权')); return }
+            required: true,
+            validator: (rule, value, callback) => {
+              if (value == 0) {
+                callback(new Error('请输入水权'));
+                return;
+              }
+              if (+value < 0) {
+                callback(new Error('水权不能为负数'));
+                return;
+              }
+              if (isNaN(value)) {
+                callback(new Error('请正确输入您的水权'));
+                return;
+              }
               if (this.isEdit) {
-                if (+value > (+this.residualWaterRight) + (+this.editFarmerData.farmerWramount)) {
-                  callback(new Error('输入的水权不能大于剩余水权'))
-                  return
-                } else { 
-                  callback()
+                if (
+                  +value >
+                  +this.residualWaterRight + +this.editFarmerData.farmerWramount
+                ) {
+                  callback(new Error('输入的水权不能大于剩余水权'));
+                  return;
+                } else {
+                  callback();
                 }
-              } else { 
+              } else {
                 if (+value > +this.residualWaterRight) {
-                  callback(new Error('输入的水权不能大于剩余水权'))
-                  return
-                } else { 
-                  callback()
+                  callback(new Error('输入的水权不能大于剩余水权'));
+                  return;
+                } else {
+                  callback();
                 }
               }
-            }, trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ]
       }
     };
@@ -292,17 +331,17 @@ export default {
         this.dialogVisible = val;
       }
       if (!val) {
-        this.$refs.baseForm?.clearValidate()
-        this.baseForm = { areaId:'' }
-        this.$emit('closeHandler')
-        this.cusareaName = ''
-        this.clearItem()
+        this.$refs.baseForm?.clearValidate();
+        this.baseForm = { areaId: '' };
+        this.$emit('closeHandler');
+        this.cusareaName = '';
+        this.clearItem();
       }
     },
     'baseForm.farmerAreasize': {
       handler(val) {
-        if (this.yieldPer > 0) { 
-          this.baseForm.farmerWramount = Number(this.yieldPer) * val
+        if (this.yieldPer > 0) {
+          this.baseForm.farmerWramount = Number(this.yieldPer) * val;
         }
       },
       deep: true,
@@ -310,12 +349,12 @@ export default {
     },
     editFarmerData: {
       handler(val) {
-        if (this.isEdit && val?.areaId) { 
-          this.baseForm = { ...val }
-          this.handlerClick(val)
+        if (this.isEdit && val?.areaId) {
+          this.baseForm = { ...val };
+          this.handlerClick(val);
         } else {
-          this.baseForm = { areaId: '' }
-          this.cusareaName =  ''
+          this.baseForm = { areaId: '' };
+          this.cusareaName = '';
         }
       },
       deep: true
@@ -329,79 +368,85 @@ export default {
     },
     'baseForm.areaId': {
       handler(val) {
-        val && this.$refs.baseForm?.clearValidate('areaId')
+        val && this.$refs.baseForm?.clearValidate('areaId');
       },
       deep: true
     }
   },
   methods: {
-    setItem(value) { 
-      this.areaAll = value?.waterrightAreasize || '0'
-      this.areaAll = (+this.areaAll).toFixed(2)
-      this.waterRightAll = value?.waterrightAmount || '0'
-      this.waterRightAll = (+this.waterRightAll).toFixed(2)
-      this.yieldPer = value ? value?.waterrightAmount == 0 ? 0 : (value?.waterrightAreasize) / (value?.waterrightAmount) : 0
-      this.yieldPer = (+this.yieldPer).toFixed(2)
-      this.residualWaterRight = value?.amountResidue ?? 0
-      this.areasizeResidue = value?.areasizeResidue ?? 0
-      this.residualWaterRight = (+this.residualWaterRight).toFixed(2)
+    setItem(value) {
+      this.areaAll = value?.waterrightAreasize || '0';
+      this.areaAll = (+this.areaAll).toFixed(2);
+      this.waterRightAll = value?.waterrightAmount || '0';
+      this.waterRightAll = (+this.waterRightAll).toFixed(2);
+      this.yieldPer = value
+        ? value?.waterrightAreasize == 0
+          ? 0
+          : value?.waterrightAmount / value?.waterrightAreasize
+        : 0;
+      this.yieldPer = (+this.yieldPer).toFixed(2);
+      this.residualWaterRight = value?.amountResidue ?? 0;
+      this.areasizeResidue = value?.areasizeResidue ?? 0;
+
+      console.log(value, 'set item ------ 1212333');
+      this.residualWaterRight = (+this.residualWaterRight).toFixed(2);
     },
-    clearItem() { 
-      this.areaAll = 0.00
-      this.waterRightAll = 0.00
-      this.yieldPer = 0.00
-      this.residualWaterRight = 0.00
+    clearItem() {
+      this.areaAll = 0.0;
+      this.waterRightAll = 0.0;
+      this.yieldPer = 0.0;
+      this.residualWaterRight = 0.0;
     },
-    findItemByAreaId(areaId,list) {
-      return list.find(item => item.areaId === areaId)
+    findItemByAreaId(areaId, list) {
+      return list.find((item) => item.areaId === areaId);
     },
     async handlerClick(item) {
       const res = await getAreaInfo({
         waterrightYear: new Date().getFullYear(),
         areaId: item.areaId
-      })
-      this.currentItem = item
-      const value = res?.data
-      this.cusareaName = item?.cusareaName
-      const areaId = item?.areaId || ''
-      this.baseForm.areaId = areaId
-      this.$set(this.baseForm,'areaId', areaId)
-      this.setItem(value)
+      });
+      this.currentItem = item;
+      const value = res?.data;
+      this.cusareaName = item?.cusareaName;
+      const areaId = item?.areaId || '';
+      this.baseForm.areaId = areaId;
+      this.$set(this.baseForm, 'areaId', areaId);
+      this.setItem(value);
     },
     resetForm() {
       this.dialogVisible = false;
-      this.cusareaName = ''
+      this.cusareaName = '';
     },
     async handlerAddFarmer() {
       if (this.currentItem?.children?.length > 0) {
-        Message.warning('请选择最小行政区块')
-        return
-       }
-      if(!this.isEdit){
-        const res = await addFarmer(this.baseForm)
-        if(res?.code === "000000") {
-          this.handleClose()
-          this.cusareaName = ''
-          this.$emit('refresh')
+        Message.warning('请选择最小行政区块');
+        return;
+      }
+      if (!this.isEdit) {
+        const res = await addFarmer(this.baseForm);
+        if (res?.code === '000000') {
+          this.handleClose();
+          this.cusareaName = '';
+          this.$emit('refresh');
         }
-      }else{
-        const res = await editFarmer(this.baseForm)
-        if(res?.code === "000000") {
-          this.handleClose()
-          this.cusareaName = ''
-          this.$emit('refresh')
+      } else {
+        const res = await editFarmer(this.baseForm);
+        if (res?.code === '000000') {
+          this.handleClose();
+          this.cusareaName = '';
+          this.$emit('refresh');
         }
       }
     },
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
-        valid && this.handlerAddFarmer()
-      })
+        valid && this.handlerAddFarmer();
+      });
     },
     handleClose() {
       this.$emit('update:visible', false);
       this.resetForm('baseForm');
-    },
+    }
   }
 };
 </script>
@@ -410,18 +455,18 @@ export default {
 .input-number {
   width: 100%;
 }
-.el-col-5{
-  width:auto;
+.el-col-5 {
+  width: auto;
   min-width: 20%;
 }
-.area{
-  margin:0 0 20px 20px;
+.area {
+  margin: 0 0 20px 20px;
   display: flex;
-  .el-col{
+  .el-col {
     min-width: 25%;
   }
-  label{
-    color:#999;
+  label {
+    color: #999;
     font-weight: 400;
     font-size: 14px;
   }
@@ -432,11 +477,11 @@ export default {
   overflow-x: hidden;
   padding: 0 20px;
 }
-.history{
+.history {
   text-align: right;
   line-height: 32px;
-  span{
-    color:rgb(20, 164, 120);
+  span {
+    color: rgb(20, 164, 120);
     cursor: pointer;
   }
 }

+ 28 - 28
src/views/waterManage/index.vue

@@ -64,14 +64,14 @@
         </el-col>
       </el-card>
     </el-col>
-  <association-manage
-    :visible.sync="associationManageShow"
-    :treeData="treeData2"
-    :userList="userList"
-    @getList="handleSearch"
-    :typeAssoc="typeAssoc"
-    :editRow="editRow"
-  />
+    <association-manage
+      :visible.sync="associationManageShow"
+      :treeData="treeData2"
+      :userList="userList"
+      @getList="handleSearch"
+      :typeAssoc="typeAssoc"
+      :editRow="editRow"
+    />
   </el-row>
 </template>
 
@@ -84,7 +84,7 @@ import SelectTree from '@/components/SelectTree';
 import { getTree } from '@/api/tree.js';
 import { Message } from 'element-ui';
 import { assign, omit } from 'lodash-es';
-import { deepClone } from '@/utils/index.js'
+import { deepClone } from '@/utils/index.js';
 
 export default {
   name: 'waterManage',
@@ -123,12 +123,12 @@ export default {
           customRender: '',
           align: 'center'
         },
-        {
-          label: '电话',
-          prop: 'userMobile',
-          customRender: '',
-          align: 'center'
-        },
+        // {
+        //   label: '电话',
+        //   prop: 'userMobile',
+        //   customRender: '',
+        //   align: 'center'
+        // },
         {
           label: '操作',
           customRender: 'operate',
@@ -174,25 +174,25 @@ export default {
           res = await getTree();
           this.$store.dispatch('tree/setTree', res);
         }
-        this.treeData = res?.data
-        this.treeData2 = []
-        this.treeData2 = deepClone(res?.data)
-        this.treeData2 = this.treeData2.filter(t => t?.cusareaName != '全部')
-        let tflag = true
-        this.treeData.forEach(t => { 
-          if (t?.cusareaName == '全部') { 
-            tflag = false
+        this.treeData = res?.data;
+        this.treeData2 = [];
+        this.treeData2 = deepClone(res?.data);
+        this.treeData2 = this.treeData2.filter((t) => t?.cusareaName != '全部');
+        let tflag = true;
+        this.treeData.forEach((t) => {
+          if (t?.cusareaName == '全部') {
+            tflag = false;
           }
-        })
-        if (tflag) { 
+        });
+        if (tflag) {
           this.treeData.unshift({
             id: '',
             cusareaId: '',
             cusareaName: '全部'
-          })
+          });
         }
-        this.cusareaName ||= this.treeData[0].cusareaName
-        this.areaId = this.treeData[0].cusareaId
+        this.cusareaName ||= this.treeData[0].cusareaName;
+        this.areaId = this.treeData[0].cusareaId;
       }
       const params = {
         assocName: this.assocName,

+ 85 - 65
src/views/waterSubsidy/components/newPolicy.vue

@@ -16,36 +16,49 @@
       :model="baseForm"
       :rules="rules"
       size="small"
-      style="height:600px;"
+      style="height: 600px"
     >
       <el-row>
         <el-form-item label="标题:" prop="subsidypolicyTitle">
           <el-input
             placeholder="请输入"
             maxlength="50"
-            v-model="baseForm.subsidypolicyTitle">
+            v-model="baseForm.subsidypolicyTitle"
+          >
           </el-input>
         </el-form-item>
       </el-row>
       <el-row>
         <el-form-item label="图片:" prop="src">
-           <el-upload
-             ref="uploader"
-             class="avatar-uploader"
-             :action="uploadUrl"
-             :show-file-list="false"
-             :on-success="handleAvatarSuccess"
-             :on-error="handleUploadError"
-             name="file"
-             :headers="headers"
-             :before-upload="beforeAvatarUpload">
-             <img v-if="baseForm.src" :src="baseForm.src | formatImg" class="avatar">
-             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
-           </el-upload>
-           <span style="color:#F56C6C">仅支持上传jpg/jpeg/png且大小不超过5M的图片</span>
+          <image-upload
+            v-model="baseForm.src"
+            :limit="1"
+            :uploadType="imageUploadType"
+          />
+          <!-- <el-upload
+            ref="uploader"
+            class="avatar-uploader"
+            :action="uploadUrl"
+            :show-file-list="false"
+            :on-success="handleAvatarSuccess"
+            :on-error="handleUploadError"
+            name="file"
+            :headers="headers"
+            :before-upload="beforeAvatarUpload"
+          >
+            <img
+              v-if="baseForm.src"
+              :src="baseForm.src | formatImg"
+              class="avatar"
+            />
+            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+          </el-upload>
+          <span style="color: #f56c6c"
+            >仅支持上传jpg/jpeg/png且大小不超过5M的图片</span
+          > -->
         </el-form-item>
       </el-row>
-      <el-row style="height: 200px;">
+      <el-row style="height: 200px">
         <el-form-item label="内容:" prop="subsidypolicyContent">
           <Editor
             style="height: 300px"
@@ -57,13 +70,13 @@
       </el-row>
     </el-form>
 
-    <div style="text-align: right;margin-top:20px;" class="button-container">
+    <div style="text-align: right; margin-top: 20px" class="button-container">
       <el-button type="info" plain @click="resetForm('baseForm')"
         >取消</el-button
       >
       <el-button
         type="primary"
-        style="margin-left:16px;"
+        style="margin-left: 16px"
         @click="submitForm('baseForm')"
         :disabled="dialogSubmitLoading"
         :loading="dialogSubmitLoading"
@@ -74,13 +87,18 @@
 </template>
 
 <script>
-import { addSubsidyPolicy, editSubsidyPolicy } from '@/api/subsidypolicy/index.js'
-import { getToken } from "@/utils/auth";
+import {
+  addSubsidyPolicy,
+  editSubsidyPolicy
+} from '@/api/subsidypolicy/index.js';
+import { getToken } from '@/utils/auth';
 import { checkEmpty } from '@/utils/index';
-import { Message } from 'element-ui'
+import { Message } from 'element-ui';
 import { assign } from 'lodash-es';
+import { UPLOAD_TYPE_MAP } from '@/utils/constants';
+
 export default {
-  name:'newPolicy',
+  name: 'newPolicy',
   props: {
     data: {
       default() {
@@ -93,7 +111,7 @@ export default {
     },
     editRow: {
       type: Object,
-      default: () => { }
+      default: () => {}
     },
     areaId: {
       type: String
@@ -104,18 +122,19 @@ export default {
   },
   data() {
     return {
-      uploadUrl: process.env.VUE_APP_BASE_API + "/wpr/subsidypolicy/preview/upload", // 上传的图片服务器地址
+      uploadUrl:
+        process.env.VUE_APP_BASE_API + '/wpr/subsidypolicy/preview/upload', // 上传的图片服务器地址
       headers: {
-        Authorization: "Bearer " + getToken()
+        Authorization: 'Bearer ' + getToken()
       },
       textarea: '',
       editor: null,
-      decisionContent:"",
+      decisionContent: '',
       mode: 'default',
       dialogSubmitLoading: false,
       dialogVisible: false,
       src: '',
-      baseForm:  {
+      baseForm: {
         subsidypolicyTitle: '',
         src: '',
         subsidypolicyContent: ''
@@ -126,23 +145,24 @@ export default {
         subsidypolicyTitle: [
           { required: true, message: '请输入您的标题', trigger: 'blur' }
         ],
-        src: [
-          { required: true, message: '请选择您的图片', trigger: 'change' }
-        ],
+        src: [{ required: true, message: '请选择您的图片', trigger: 'change' }],
         subsidypolicyContent: [
           {
-            required: true, validator: (rule, value, callback) => {
+            required: true,
+            validator: (rule, value, callback) => {
               if (!value) callback(new Error('请输入内容'));
-              const vaild = !checkEmpty(value)
+              const vaild = !checkEmpty(value);
               if (vaild) {
-                callback()
+                callback();
               } else {
                 callback(new Error('请输入内容'));
               }
-
-            }, trigger: 'blur' }
+            },
+            trigger: 'blur'
+          }
         ]
-      }
+      },
+      imageUploadType: UPLOAD_TYPE_MAP.POLICY
     };
   },
   watch: {
@@ -162,56 +182,54 @@ export default {
     },
     editRow: {
       handler(val) {
-        this.baseForm = { ...this.editRow }
+        this.baseForm = { ...this.editRow };
       },
       deep: true
     },
     'baseForm.src'(val) {
-      if(val) this.$refs.baseForm.clearValidate(['src'])
+      if (val) this.$refs.baseForm.clearValidate(['src']);
     },
     'baseForm.subsidypolicyContent'(val) {
       if (!checkEmpty(val)) {
-        this.$refs?.baseForm?.clearValidate(['subsidypolicyContent'])
+        this.$refs?.baseForm?.clearValidate(['subsidypolicyContent']);
       } else {
-        this.$refs?.baseForm?.validateField('subsidypolicyContent')
+        this.$refs?.baseForm?.validateField('subsidypolicyContent');
       }
-     }
+    }
   },
   methods: {
     onCreated(editor) {
-      this.editor = Object.seal(editor)
+      this.editor = Object.seal(editor);
     },
     handleAvatarSuccess(res, file) {
-      this.resId = res?.data?.resId
+      this.resId = res?.data?.resId;
       this.baseForm.src = URL.createObjectURL(file.raw);
     },
     handleUploadError() {
-      Message.error("图片插入失败");
+      Message.error('图片插入失败');
     },
     beforeAvatarUpload(file) {
       const fileName = file.name;
       const fileType = fileName.substring(fileName.lastIndexOf('.'));
       const isOKType =
-        fileType === '.jpg' ||
-        fileType === '.png' ||
-        fileType === '.jpeg';
+        fileType === '.jpg' || fileType === '.png' || fileType === '.jpeg';
       const isLt2M = file.size / 1024 / 1024 < 5;
       if (!isLt2M) {
         Message({
           type: 'error',
           message: '上传头像图片大小不能超过 5MB!'
-        })
+        });
       }
       return isOKType && isLt2M;
     },
     resetForm() {
       this.dialogVisible = false;
-      this.resetFormData()
+      this.resetFormData();
       setTimeout(() => {
         this.$refs.baseForm.clearValidate();
-      })
+      });
     },
-    
+
     resetFormData() {
       this.baseForm = {
         subsidypolicyTitle: '',
@@ -220,36 +238,38 @@ export default {
       };
     },
     async addSubsidyPolicyHandler() {
+      const resId = this.baseForm.src ? this.baseForm.src.resId : '';
+
       if (this.policyType == 'add') {
         const params = {
           areaIds: this.areaId,
-          resIds: this.resId,
+          resIds: resId,
           subsidypolicyContent: this.baseForm.subsidypolicyContent,
           subsidypolicyTitle: this.baseForm.subsidypolicyTitle
-        }
-        await addSubsidyPolicy(params)
-      } else { 
+        };
+        await addSubsidyPolicy(params);
+      } else {
         const params = {
           areaIds: this.areaId,
-          resIds: this.resId,
+          resIds: resId,
           subsidypolicyContent: this.baseForm.subsidypolicyContent,
           subsidypolicyTitle: this.baseForm.subsidypolicyTitle,
           subsidypolicyId: this.baseForm.subsidypolicyId
-        }
-        await editSubsidyPolicy(params)
+        };
+        await editSubsidyPolicy(params);
       }
-      this.handleClose()
-      this.$emit('addSuccess')
+      this.handleClose();
+      this.$emit('addSuccess');
     },
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
-        valid && this.addSubsidyPolicyHandler()
-      })
+        valid && this.addSubsidyPolicyHandler();
+      });
     },
     handleClose() {
       this.$emit('update:visible', false);
       this.resetForm('baseForm');
-    },
+    }
   }
 };
 </script>
@@ -263,7 +283,7 @@ export default {
   overflow: hidden;
 }
 ::v-deep.avatar-uploader .el-upload:hover {
-  border-color: #409EFF;
+  border-color: #409eff;
 }
 ::v-deep.avatar-uploader-icon {
   font-size: 28px;

+ 10 - 10
src/views/waterSubsidy/index.vue

@@ -41,7 +41,7 @@
             <template #styleImg="scope">
               <el-image
                 :src="scope.row.previews | formatImg"
-                :preview-src-list="[dialogImageUrl + scope.row.previews || '']"
+                :preview-src-list="[scope.row.previews || '']"
                 slot="error"
                 class="image-slot"
                 style="width: 100px; height: 50px"
@@ -172,22 +172,22 @@ export default {
           res = await getTree();
           this.$store.dispatch('tree/setTree', res);
         }
-        this.treeData = res?.data
-        let tflag = true
-        this.treeData.forEach(t => {
+        this.treeData = res?.data;
+        let tflag = true;
+        this.treeData.forEach((t) => {
           if (t?.cusareaName == '全部') {
-            tflag = false
+            tflag = false;
           }
-        })
+        });
         if (tflag) {
           this.treeData.unshift({
             id: '',
             cusareaId: '',
             cusareaName: '全部'
-          })
+          });
         }
-        this.cusareaName ||= this.treeData[0].cusareaName
-        this.areaId = this.treeData[0].cusareaId
+        this.cusareaName ||= this.treeData[0].cusareaName;
+        this.areaId = this.treeData[0].cusareaId;
       }
       const params = {
         areaIds: this.areaId,
@@ -212,7 +212,7 @@ export default {
       this.policyType = 'edit';
       const params = {
         subsidypolicyTitle: row?.subsidypolicyTitle,
-        src: row?.previews,
+        src: { resId: row.resIds, url: row?.previews },
         subsidypolicyContent: row?.subsidypolicyContent,
         subsidypolicyId: row?.subsidypolicyId,
         resIds: row?.resIds