فهرست منبع

修改活动人数和会场面积

xiaodai2017 1 سال پیش
والد
کامیت
07e320aca6

+ 107 - 64
src/views/serviceParam/actNum/addEdit.vue

@@ -24,22 +24,51 @@
             label-width="80px"
             class="demo-ruleForm"
           >
-            <el-form-item label="名称" prop="name">
-              <el-input
-                v-model="ruleForm['name']"
-                :disabled="id == '007'"
-                placeholder="名称"
-                maxlength="20"
-              />
-            </el-form-item>
+            <el-row :gutter="10">
+              <el-col :span="24">
+                <el-form-item label="数据类型" prop="type">
+                  <el-select
+                    v-model="ruleForm.type"
+                    style="width: 100%"
+                    :disabled="id == '007'"
+                    placeholder="数据类型"
+                    @change="typeChange"
+                  >
+                    <el-option label="面积1~面积2 ㎡" value="1" />
+                    <el-option label="面积+ ㎡" value="2" />
+                  </el-select> </el-form-item
+              ></el-col>
+              <el-col :span="ruleForm.type === '1' ? 13 : 24">
+                <el-form-item label="会议面积" prop="min">
+                  <el-input
+                    v-model="ruleForm['min']"
+                    :disabled="id == '007'"
+                    placeholder="面积1"
+                    maxlength="20"
+                  >
+                    <template slot="append" v-if="ruleForm.type !== '1'">+</template>
+                  </el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="2" class="tc" v-if="ruleForm.type === '1'">
+                <span style="height: 40px; line-height: 40px">~</span>
+              </el-col>
+              <el-col :span="9" v-if="ruleForm.type === '1'">
+                <el-form-item label-width="0" prop="max">
+                  <el-input
+                    v-model="ruleForm['max']"
+                    :disabled="id == '007'"
+                    placeholder="面积2"
+                    maxlength="20"
+                  />
+                </el-form-item>
+              </el-col>
+            </el-row>
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
-          <el-button
-            v-if="id !== '007'"
-            type="primary"
-            @click="submitForm"
-          >保 存
+          <el-button v-if="id !== '007'" type="primary" @click="submitForm"
+            >保 存
           </el-button>
           <el-button @click="showModelThis = false">{{
             id == "007" ? "关 闭" : "取 消"
@@ -50,107 +79,121 @@
   </el-dialog>
 </template>
 <script>
-import asyncRequest from '@/apis/service/serviceParam/actNum'
-import resToken from '@/mixins/resToken'
+import asyncRequest from "@/apis/service/serviceParam/actNum";
+import resToken from "@/mixins/resToken";
 
 /**
  * @props
  * 名称 name
  * */
 export default {
-  name: 'Brand',
+  name: "actNum",
   mixins: [resToken],
-  props: ['showModel', 'id', 'sitem'],
+  props: ["showModel", "id", "sitem"],
   data() {
     return {
       loading: false,
-      title: '添加活动人数',
+      title: "添加活动人数",
       showModelThis: this.showModel,
-      select: '1',
+      select: "1",
       activeOptions: [],
       actionList: [],
       ruleForm: {
-        id: '',
-        名称:""
+        id: "",
+        type: "1",
+        min: "",
+        max: "",
       },
       rulesThis: this.rules,
       rules: {
-        name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
-      }
-    }
+        type: [{ required: true, message: "请选择数据类型", trigger: "change" }],
+        min: [{ required: true, message: "最小面积不能为空", trigger: "blur" }],
+        max: [{ required: true, message: "最大面积不能为空", trigger: "blur" }],
+      },
+    };
   },
   watch: {
-    showModel: function(val) {
-      this.showModelThis = val
+    showModel: function (val) {
+      this.showModelThis = val;
       if (val) {
-        this.initForm()
+        this.initForm();
       }
     },
     showModelThis(val) {
       if (!val) {
-        this.$emit('cancel')
+        this.$emit("cancel");
       }
-    }
+    },
   },
   methods: {
     async initForm() {
-      this.loading = true
-      const basicTitle = '活动人数'
-      let prefix = this.id === '005' ? '修改' : this.id === '002' ? '添加' : ''
-      this.title = prefix ? prefix + basicTitle : basicTitle + '详情'
-      await this.resetForm()
-      this.loading = false
+      this.loading = true;
+      const basicTitle = "活动人数";
+      let prefix = this.id === "005" ? "修改" : this.id === "002" ? "添加" : "";
+      this.title = prefix ? prefix + basicTitle : basicTitle + "详情";
+      await this.resetForm();
+      this.loading = false;
     },
     async resetForm() {
       // 重置
       await this.$nextTick(() => {
         if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields()
-          this.$refs.ruleForm.clearValidate()
-          const { id, name } = this.sitem
+          this.$refs.ruleForm.resetFields();
+          this.$refs.ruleForm.clearValidate();
+          const { id, min, max } = this.sitem;
+          const isok = String(max) === "0";
           this.ruleForm = {
-            id: id || '',
-            name: name || ''
-          }
+            id: id || "",
+            type: isok ? "2" : "1",
+            min: min || "",
+            max: max || "",
+          };
         }
-      })
+      });
+    },
+    typeChange() {
+      const { type } = this.ruleForm;
+      this.rulesThis.max[0].required = type === "1";
     },
     async submitForm() {
-      await this.$refs.ruleForm.validate(async(valid) => {
+      await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           if (!this.loading) {
-            this.loading = true
-            const model = JSON.parse(JSON.stringify(this.ruleForm))
-            let res = {}
-            if (this.id === '002') {
-              delete model['id']
-              res = await asyncRequest.add(model)
+            this.loading = true;
+            let model = JSON.parse(JSON.stringify(this.ruleForm));
+            if (model.type === "2") {
+              model.max = "";
+            }
+            let res = {};
+            if (this.id === "002") {
+              delete model["id"];
+              res = await asyncRequest.add(model);
             } else {
-              res = await asyncRequest.update(model)
+              res = await asyncRequest.update(model);
             }
-            this.loading = false
+            this.loading = false;
             if (res && res.code === 1) {
-              const title = this.id === '002' ? '添加成功!' : '修改成功!'
+              const title = this.id === "002" ? "添加成功!" : "修改成功!";
               this.$notify.success({
                 title,
-                message: ''
-              })
-              this.showModelThis = false
+                message: "",
+              });
+              this.showModelThis = false;
               // 刷新
-              this.$emit('refresh')
-            } 
+              this.$emit("refresh");
+            }
           }
         } else {
-          console.log('error submit!!')
-          return false
+          console.log("error submit!!");
+          return false;
         }
-      })
-    }
-  }
-}
+      });
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
-.brand {
+.actNum {
 }
 </style>

+ 14 - 6
src/views/serviceParam/actNum/index.vue

@@ -23,7 +23,7 @@
       <template #table-header="{}">
         <div style="width: 100%">
           <el-row style="padding: 0 0 0 80px">
-            <el-col :span="4" style="margin-right: 10px">
+            <!-- <el-col :span="4" style="margin-right: 10px">
               <el-input
                 :size="searchSize"
                 v-model="parmValue.name"
@@ -41,7 +41,7 @@
                 "
                 placeholder="活动人数"
               ></el-input>
-            </el-col>
+            </el-col> -->
 
             <el-col :span="4" style="width: 160px">
               <el-select
@@ -94,13 +94,20 @@
           </el-row>
         </div></template
       >
+
+      <template #name="{ scope }">
+        <span v-if="String(scope.row.max) === '0'">{{ scope.row.min }}+ ㎡</span>
+        <span v-else>{{ scope.row.min }}~{{ scope.row.max }} ㎡</span>
+      </template>
       <template #status="{ scope }">
         <el-tag
           :size="tablebtnSize"
           :type="scope.row.status == '0' ? 'warning' : ''"
           v-text="
-          (statusList.find((item) => Number(item.code) == Number(scope.row.status)) || {}).name ||
-            '--'
+            (
+              statusList.find((item) => Number(item.code) == Number(scope.row.status)) ||
+              {}
+            ).name || '--'
           "
         ></el-tag>
       </template>
@@ -220,6 +227,7 @@ export default {
         {
           prop: "name",
           label: "活动人数",
+          _slot_: "name",
         },
         {
           prop: "status",
@@ -325,7 +333,7 @@ export default {
     },
     // 刷新表格
     async searchList() {
-      if(this.loading) return
+      if (this.loading) return;
       this.loading = true;
       const model = {
         ...this.parmValue,
@@ -333,7 +341,7 @@ export default {
       };
       const { code, data } = await asyncRequest.list(model);
       if (code === 1) {
-        const { list,total } = data;
+        const { list, total } = data;
         this.tableData = list;
         this.pageInfo.total = Number(total);
       } else {

+ 51 - 26
src/views/serviceParam/area/addEdit.vue

@@ -21,34 +21,48 @@
             :model="ruleForm"
             status-icon
             :rules="rules"
-            label-width="0"
+            label-width="80px"
             class="demo-ruleForm"
           >
             <el-row :gutter="10">
-              <el-col :span="8">最小面积</el-col>
-              <el-col :span="8">&nbsp;</el-col>
-              <el-col :span="8">最大面积</el-col>
-              <el-col :span="8">
-                <el-form-item prop="min">
+              <el-col :span="24">
+                <el-form-item label="数据类型" prop="type">
+                  <el-select
+                    v-model="ruleForm.type"
+                    style="width: 100%"
+                    :disabled="id == '007'"
+                    placeholder="数据类型"
+                    @change="typeChange"
+                  >
+                    <el-option label="面积1~面积2 ㎡" value="1" />
+                    <el-option label="面积+ ㎡" value="2" />
+                  </el-select> </el-form-item
+              ></el-col>
+              <el-col :span="ruleForm.type === '1' ? 13 : 24">
+                <el-form-item label="会议面积" prop="min">
                   <el-input
-                    type="number"
-                    v-model="ruleForm.min"
+                    v-model="ruleForm['min']"
                     :disabled="id == '007'"
-                    placeholder="最小面积"
+                    placeholder="面积1"
                     maxlength="20"
-                  /> </el-form-item
-              ></el-col>
-              <el-col :span="8" class="tc"> 实际面积 </el-col>
-              <el-col :span="8">
-                <el-form-item prop="name">
+                  >
+                    <template slot="append" v-if="ruleForm.type !== '1'">+</template>
+                  </el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="2" class="tc" v-if="ruleForm.type === '1'">
+                <span style="height: 40px; line-height: 40px">~</span>
+              </el-col>
+              <el-col :span="9" v-if="ruleForm.type === '1'">
+                <el-form-item label-width="0" prop="max">
                   <el-input
-                    type="number"
-                    v-model="ruleForm.max"
+                    v-model="ruleForm['max']"
                     :disabled="id == '007'"
-                    placeholder="名称"
+                    placeholder="面积2"
                     maxlength="20"
-                  /> </el-form-item
-              ></el-col>
+                  />
+                </el-form-item>
+              </el-col>
             </el-row>
           </el-form>
         </el-col>
@@ -73,7 +87,7 @@ import resToken from "@/mixins/resToken";
  * 名称 name
  * */
 export default {
-  name: "Brand",
+  name: "area",
   mixins: [resToken],
   props: ["showModel", "id", "sitem"],
   data() {
@@ -86,11 +100,13 @@ export default {
       actionList: [],
       ruleForm: {
         id: "",
-        min: 0,
-        max: 100,
+        type: "1",
+        min: "",
+        max: "",
       },
       rulesThis: this.rules,
       rules: {
+        type: [{ required: true, message: "请选择数据类型", trigger: "change" }],
         min: [{ required: true, message: "最小面积不能为空", trigger: "blur" }],
         max: [{ required: true, message: "最大面积不能为空", trigger: "blur" }],
       },
@@ -125,20 +141,29 @@ export default {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
           const { id, min, max } = this.sitem;
+          const isok = String(max) === "0";
           this.ruleForm = {
             id: id || "",
-            min: min || 0,
-            max: max || 100,
+            type: isok ? "2" : "1",
+            min: min || "",
+            max: max || "",
           };
         }
       });
     },
+    typeChange() {
+      const { type } = this.ruleForm;
+      this.rulesThis.max[0].required = type === "1";
+    },
     async submitForm() {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           if (!this.loading) {
             this.loading = true;
-            const model = JSON.parse(JSON.stringify(this.ruleForm));
+            let model = JSON.parse(JSON.stringify(this.ruleForm));
+            if (model.type === "2") {
+              model.max = "";
+            }
             let res = {};
             if (this.id === "002") {
               delete model["id"];
@@ -169,6 +194,6 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-.brand {
+.area {
 }
 </style>

+ 18 - 10
src/views/serviceParam/area/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="actNum pagePadding">
+  <div class="area pagePadding">
     <ex-table
       v-loading="loading"
       :table="table"
@@ -23,7 +23,7 @@
       <template #table-header="{}">
         <div style="width: 100%">
           <el-row style="padding: 0 0 0 80px">
-            <el-col :span="4" style="margin-right: 10px">
+            <!-- <el-col :span="4" style="margin-right: 10px">
               <el-input
                 :size="searchSize"
                 v-model="parmValue.name"
@@ -41,7 +41,7 @@
                 "
                 placeholder="活动人数"
               ></el-input>
-            </el-col>
+            </el-col> -->
 
             <el-col :span="4" style="width: 160px">
               <el-select
@@ -94,13 +94,20 @@
           </el-row>
         </div></template
       >
+
+      <template #name="{ scope }">
+        <span v-if="String(scope.row.max) === '0'">{{ scope.row.min }}+ ㎡</span>
+        <span v-else>{{ scope.row.min }}~{{ scope.row.max }} ㎡</span>
+      </template>
       <template #status="{ scope }">
         <el-tag
           :size="tablebtnSize"
           :type="scope.row.status == '0' ? 'warning' : ''"
           v-text="
-          (statusList.find((item) => Number(item.code) == Number(scope.row.status)) || {}).name ||
-            '--'
+            (
+              statusList.find((item) => Number(item.code) == Number(scope.row.status)) ||
+              {}
+            ).name || '--'
           "
         ></el-tag>
       </template>
@@ -173,7 +180,7 @@ import mixinPage from "@/mixins/elPaginationHandle";
 import { mapGetters } from "vuex";
 import resToken from "@/mixins/resToken";
 export default {
-  name: "actNum",
+  name: "area",
   mixins: [mixinPage, resToken],
   components: {
     addEdit,
@@ -183,7 +190,7 @@ export default {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       const tran =
-        this.$store.getters.btnList.find((i) => i.menu_route == "actNum") || {};
+        this.$store.getters.btnList.find((i) => i.menu_route == "area") || {};
       const { action } = tran ?? {};
       return action ?? [];
     },
@@ -219,7 +226,8 @@ export default {
       columns: [
         {
           prop: "name",
-          label: "活动人数",
+          label: "会场面积",
+          _slot_: "name",
         },
         {
           prop: "status",
@@ -325,7 +333,7 @@ export default {
     },
     // 刷新表格
     async searchList() {
-      if(this.loading) return
+      if (this.loading) return;
       this.loading = true;
       const model = {
         ...this.parmValue,
@@ -333,7 +341,7 @@ export default {
       };
       const { code, data } = await asyncRequest.list(model);
       if (code === 1) {
-        const { list,total } = data;
+        const { list, total } = data;
         this.tableData = list;
         this.pageInfo.total = Number(total);
       } else {