From 1bdf1c1ef2ad11b31f10cd21d71b575c7b4a72c4 Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期五, 10 十一月 2023 19:47:39 +0800
Subject: [PATCH] 	modified:   src/views/basic/param/index.vue

---
 src/views/basic/param/index.vue |  311 ++++++++++++++++++++++++++-------------------------
 1 files changed, 160 insertions(+), 151 deletions(-)

diff --git a/src/views/basic/param/index.vue b/src/views/basic/param/index.vue
index 5754c52..03c511f 100644
--- a/src/views/basic/param/index.vue
+++ b/src/views/basic/param/index.vue
@@ -1,97 +1,83 @@
 <template>
   <div>
     <div class="param-basic">
-        <el-form style="width:100%;margin-top: 20px;" class="l-mes" :inline="true" :model="searchForm">
-          <el-row>
-            <el-col :span="4">
-              <el-form-item label="鍙傛暟椤�:">
-                <el-input clearable style="width: 100%;" v-model="searchForm.param" placeholder="鍙傛暟椤�"></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="5">
-              <el-form-item label="鍙傛暟缂栧彿:">
-                <el-input clearable style="width: 100%;" v-model="searchForm.code" placeholder="鍙傛暟缂栧彿"></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="6">
-              <el-form-item  class="btn-group">
-                <el-button type="" @click="onSearch">鏌ヨ</el-button>
-                <el-button type="primary" @click="addOrUpdateHandle">鏂板</el-button>
-                <el-button @click="showImportDialog">瀵煎叆</el-button>
-              </el-form-item>
-            </el-col>
-          </el-row>
-        </el-form>
+      <el-form style="width:100%;margin-top: 20px;" class="l-mes" :inline="true" :model="searchForm">
+        <el-row>
+          <el-col :span="4">
+            <el-form-item label="鍙傛暟椤�:">
+              <el-input clearable style="width: 100%;" v-model="searchForm.param" placeholder="鍙傛暟椤�"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="5">
+            <el-form-item label="鍙傛暟缂栧彿:">
+              <el-input clearable style="width: 100%;" v-model="searchForm.code" placeholder="鍙傛暟缂栧彿"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item class="btn-group">
+              <el-button type="" @click="onSearch">鏌ヨ</el-button>
+              <el-button type="primary" @click="addOrUpdateHandle">鏂板</el-button>
+              <el-button @click="showImportDialog">瀵煎叆</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
     </div>
     <basic-container>
-        <avue-crud :data="tableData"
-              ref="crud"
-             :option="option"
-             :span-method="spanMethod"
-             @refresh-change="getData"
-             :page="page"
-             :table-loading="loading"
-             @row-update="updateParam"
-             @row-del="delParam">
-             <template #menu="{row,index}">
-              <el-button type="text" icon="el-icon-edit" size="small" @click="showEdit(row,index)">缂栬緫</el-button>
-              <el-button type="text" icon="el-icon-delete" size="small" @click="showDel(row,index)">鍒犻櫎</el-button>
-            </template>
-             <template slot-scope="scope" slot="paramTypeForm">
-                <el-select v-model="scope.row.paramType" @change="changeType(scope.row)" 
-                filterable placeholder="璇烽�夋嫨鍙傛暟绫诲瀷" :disabled="formDisabled">
-                  <el-option v-for="(item,index) in typeOptions" 
-                  :key="index" :label="item.label" :value="item.value"/>
-                </el-select>
-             </template>
-             <template slot="paramFormatLabel" slot-scope="scope">
-                <span v-if="scope.row.paramType!='2'">鍙傛暟鏍煎紡</span>
-                <span v-else>鏁版嵁瀛楀吀</span>
-             </template>
-             <template slot-scope="scope" slot="paramFormatForm">
-               <el-input v-if="scope.row.paramType!='2'" v-model="scope.row.paramFormat" 
-               placeholder="璇疯緭鍏ュ弬鏁版牸寮�" :disabled="formDisabled"/>
-               <el-select v-else v-model="scope.row.paramFormat" filterable 
-               placeholder="璇烽�夋嫨鏁版嵁瀛楀吀" :disabled="formDisabled">
-                 <el-option v-for="(item,index) in dictOptions" 
-                 :key="index" :label="item.description" :value="item.type"/>
-               </el-select>
-             </template>
-        </avue-crud>
+      <avue-crud :data="tableData" ref="crud" :option="option" :span-method="spanMethod" @refresh-change="getData"
+        :page="page" :table-loading="loading" @row-update="updateParam" @row-del="delParam">
+        <template #menu="{ row, index }">
+          <el-button type="text" icon="el-icon-edit" size="small" @click="showEdit(row, index)">缂栬緫</el-button>
+          <el-button type="text" icon="el-icon-delete" size="small" @click="showDel(row, index)">鍒犻櫎</el-button>
+        </template>
+        <template slot-scope="scope" slot="paramTypeForm">
+          <el-select v-model="scope.row.paramType" @change="changeType(scope.row)" filterable placeholder="璇烽�夋嫨鍙傛暟绫诲瀷"
+            :disabled="formDisabled">
+            <el-option v-for="(item, index) in typeOptions" :key="index" :label="item.label" :value="item.value" />
+          </el-select>
+        </template>
+        <template slot="paramFormatLabel" slot-scope="scope">
+          <span v-if="scope.row.paramType != '2'">鍙傛暟鏍煎紡</span>
+          <span v-else>鏁版嵁瀛楀吀</span>
+        </template>
+        <template slot-scope="scope" slot="paramFormatForm">
+          <el-input v-if="scope.row.paramType != '2'" v-model="scope.row.paramFormat" placeholder="璇疯緭鍏ュ弬鏁版牸寮�"
+            :disabled="formDisabled" />
+          <el-select v-else v-model="scope.row.paramFormat" filterable placeholder="璇烽�夋嫨鏁版嵁瀛楀吀" :disabled="formDisabled">
+            <el-option v-for="(item, index) in dictOptions" :key="index" :label="item.description" :value="item.type" />
+          </el-select>
+        </template>
+      </avue-crud>
     </basic-container>
     <!-- 寮圭獥, 鏂板 / 淇敼 -->
     <table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getData"></table-form>
-    <el-dialog
-      title="瀵煎叆"
-      :visible.sync="importDialog"
-      width="22%">
-        <el-upload ref="upload" style="width:100%;" class="upload-demo" drag action="#" 
-        :multiple="false" :file-list="fileList" :auto-upload="false" show-file-list
-        :on-change="handleUpload">
-          <i class="el-icon-upload"></i>
-          <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
-          <div class="el-upload__tip" slot="tip">
-            鍙兘涓婁紶xls/xlsx鏂囦欢锛屼笖涓嶈秴杩�10MB
-            <el-button type="text" style="font-size:15px;text-decoration: underline;" 
+    <el-dialog title="瀵煎叆" :visible.sync="importDialog" width="22%">
+      <el-upload ref="upload" style="width:100%;" class="upload-demo" drag action="#" :multiple="false"
+        :file-list="fileList" :auto-upload="false" show-file-list :on-change="handleUpload">
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+        <div class="el-upload__tip" slot="tip">
+          鍙兘涓婁紶xls/xlsx鏂囦欢锛屼笖涓嶈秴杩�10MB
+          <el-button type="text" style="font-size:15px;text-decoration: underline;"
             @click="downloadTemplate">涓嬭浇妯℃澘</el-button>
-          </div>
-        </el-upload>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="importDialog = false">鍙� 娑�</el-button>
-          <el-button type="primary" @click="confirmImport()">纭� 瀹�</el-button>
-        </span>
+        </div>
+      </el-upload>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="importDialog = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="confirmImport()">纭� 瀹�</el-button>
+      </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import { fetchList, delObj,putObj,uploadParam } from '@/api/basic/param'
+import { fetchList, delObj, putObj, uploadParam } from '@/api/basic/param'
 import { uploadTemplate } from '@/api/basic/template'
 import TableForm from './param-form'
 import { mapGetters } from 'vuex'
-import { remote,fetchList as fetchDictList } from '@/api/admin/dict'
+import { remote, fetchList as fetchDictList } from '@/api/admin/dict'
 export default {
-    data() {
+  data() {
     return {
       fileList: [],
       importDialog: false,
@@ -103,7 +89,7 @@
         code: null
       },
       loading: true,
-      page:{
+      page: {
         total: 10,
         currentPage: 1,
         pageSize: 10
@@ -145,7 +131,7 @@
             label: '鍙傛暟绫诲瀷',
             prop: 'paramType',
             formslot: true,
-            rules:[{
+            rules: [{
               required: true,
               message: "璇烽�夋嫨鍙傛暟绫诲瀷",
               trigger: "change"
@@ -159,7 +145,7 @@
           }, {
             label: '鍗曚綅',
             prop: 'unit',
-            rules:[{
+            rules: [{
               required: true,
               message: "鍗曚綅涓嶈兘涓虹┖",
               trigger: "blur"
@@ -170,7 +156,7 @@
       spanArr: [{
         prop: 'code',
         span: []
-      },{
+      }, {
         prop: 'paramItem',
         span: []
       }, {
@@ -190,13 +176,13 @@
     this.getData()
     this.getParamType()
   },
-  beforeUpdate(){
+  beforeUpdate() {
     console.log("updated");
     this.rowSort()
     this.rowCalc()
     this.loading = false
   },
-  watch:{ },
+  watch: {},
   methods: {
     //涓嬭浇妯℃澘
     downloadTemplate() {
@@ -217,47 +203,50 @@
       })
     },
     // 鏂囦欢涓婁紶
-		handleUpload(file, fileList) {
+    handleUpload(file, fileList) {
       const maxSize = 10 * 1024 * 1024 * 1024;//10MB
       const xlsType = "application/vnd.ms-excel";
       const xlsxType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-      if(file.raw.type != xlsType && file.raw.type != xlsxType){
+      if (file.raw.type != xlsType && file.raw.type != xlsxType) {
         this.$message.warning("瀵煎叆鏂囦欢鏍煎紡涓嶇锛�");
         fileList.pop()
         return;
       }
-      if(Number.parseInt(file.size) > maxSize){
+      if (Number.parseInt(file.size) > maxSize) {
         this.$message.warning("瀵煎叆鏂囦欢杩囧ぇ锛�");
         fileList.pop()
         return;
       }
-      if(fileList.length > 1){
+      if (fileList.length > 1) {
         this.$message.warning("鍙兘瀵煎叆鍗曚釜鏂囦欢!")
         fileList.pop()
       }
       this.fileList = fileList;
       // this.importFile = file;
     },
-    showImportDialog(){
+    showImportDialog() {
       this.importDialog = true
     },
     //纭畾瀵煎叆
-    confirmImport(){
+    confirmImport() {
       console.log(this.fileList)
-      const fileData =  new FormData();
+      const fileData = new FormData();
       fileData.append('file', this.fileList[0].raw);
-      uploadParam(fileData).then((res)=>{
-        console.log(res);
-        // this.exportLoading = false;
+      uploadParam(fileData).then((res) => {
+        this.$message.success("瀵煎叆鍙傛暟鎴愬姛!")
+        this.fileList = []
+        this.importDialog = false
+        this.getData()
+        this.getParamType()
       }).catch()
     },
     // 淇敼鍙傛暟绫诲瀷
     changeType(row) {
       if (row.paramType === '1') {
         row.paramFormat = '#.0000'
-      } else if(row.paramType === '2'){
+      } else if (row.paramType === '2') {
         this.getDictOptions()
-      }else {
+      } else {
         row.paramFormat = ''
       }
     },
@@ -274,81 +263,98 @@
         }
       })
     },
-    showEdit(row,index){
-      this.option.column.forEach(item=>{
-        if(row.paramItemThree=="" && item.prop=='paramItemThree'){
+    showEdit(row, index) {
+      this.option.column.forEach(item => {
+        if (row.paramItemThree == "" && item.prop == 'paramItemThree') {
           item.display = false
+        }else if(row.paramItemThree != "" && item.prop == 'paramItemThree'){
+          item.display = true
         }
-        if(row.paramItemTwo=="" && item.prop=='paramItemTwo'){
+        if (row.paramItemTwo == "" && item.prop == 'paramItemTwo') {
           item.display = false
+        }else if(row.paramItemTwo != "" && item.prop == 'paramItemTwo'){
+          item.display = true
         }
       })
-      this.$refs.crud.rowEdit(row,index)
+      console.log(row);
+      // let type=this.typeOptions.filter(t=>{
+      //   return t.label==row.paramType
+      // })[0]
+      // row.paramType=type.value
+      this.$refs.crud.rowEdit(row, index)
     },
-    showDel(row,index){
-      this.$refs.crud.rowDel(row,index)
+    showDel(row, index) {
+      this.$refs.crud.rowDel(row, index)
     },
-    updateParam(row,index,done,loading){
+    updateParam(row, index, done, loading) {
+      // console.log(row);
       // this.formDisabled = true
       let data = {
         dict: '',
-        id: 0,
+        id: '',
         parameterFormat: '',
         parameterItem: '',
         type: row.paramType,
         unit: row.unit,
       }
-      row.paramType=='2' ? data.dict=row.paramFormat : data.parameterFormat=row.paramFormat
-      if(row.threeId){
+      row.paramType == '2' ? data.dict = row.paramFormat : data.parameterFormat = row.paramFormat
+      if (row.threeId!="null") {
         data.id = row.threeId
         data.parameterItem = row.paramItemThree
-      }else{
-        if(row.twoId){
+      } else {
+        if (row.twoId!="null") {
           data.id = row.twoId
           data.parameterItem = row.paramItemTwo
-        }else{
+        } else {
           data.id = row.oneId
           data.parameterItem = row.paramItem
         }
       }
-      console.log(data)
-      putObj(data).then(res=>{
-        if(res.data.data.code==0){
+      if(data.type=='鏂囨湰鏍煎紡'){
+        let type=this.typeOptions.filter(t=>{
+        return t.label==row.paramType
+      })[0]
+      data.type=type.value
+      }
+      // console.log(data);
+      // return
+      putObj(data).then(res => {
+        if (res.data.data.code == 0) {
           this.$message.success("鏇存柊鎴愬姛")
-        }else{
+        } else {
           this.$message.error(res.data.data.msg)
         }
         this.getData()
         done(row)
-      }).catch(error=>{
+      }).catch(error => {
         console.log(error)
       })
     },
-    delParam(row){
+    delParam(row) {
       let id;
-      if(row.threeId){
+      if (row.threeId) {
         id = row.threeId
-      }else{
-        if(row.twoId){
+      } else {
+        if (row.twoId) {
           id = row.twoId
-        }else{
+        } else {
           id = row.oneId
         }
       }
-      this.$confirm('鏄惁纭鍒犻櫎缂栧彿涓恒��' + row.code+'銆戠殑鏁版嵁?', '鎻愮ず', {
-          confirmButtonText: '纭畾',
-          cancelButtonText: '鍙栨秷',
-          type: 'warning'
-        }).then(() => {
-          delObj(id).then(res=>{
-            if(res.data.code==0){
-              this.$message.success("鍒犻櫎鎴愬姛")
-            }else{
-              this.$message.error("鍒犻櫎澶辫触")
-            }
-            this.getData()
-          })
-        }).catch(() => {});
+      this.$confirm('鏄惁纭鍒犻櫎缂栧彿涓恒��' + row.code + '銆戠殑鏁版嵁?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        delObj(id).then(res => {
+          if (res.data.code == 0) {
+            this.$message.success("鍒犻櫎鎴愬姛")
+          } else {
+            this.$message.error("鍒犻櫎澶辫触")
+          }
+          this.getData()
+        })
+      }).catch(() => { });
     },
     // 鑾峰彇宸ュ簭鍙傛暟绫诲瀷
     getParamType() {
@@ -359,11 +365,12 @@
         }
       })
     },
-    onSearch() { 
+    onSearch() {
       this.getData()
     },
     // 鏂板 / 淇敼
     addOrUpdateHandle(row) {
+      console.log("1111",row);
       this.addOrUpdateVisible = true
       this.$nextTick(() => {
         this.$refs.addOrUpdate.init(row == null ? null : row.id)
@@ -385,14 +392,14 @@
       })
     },
     //鍔ㄦ�佸悎骞舵柟娉�
-    rowCalc () {
+    rowCalc() {
       this.spanArr.forEach((ele, index) => {
         let parent
         if (index !== 0) parent = this.spanArr[ele.parent || index - 1].span
         ele.span = this.rowSpan(ele.prop, parent)
       })
     },
-    rowSort (list) {
+    rowSort(list) {
       let propList = this.spanArr.map(ele => ele.prop)
       this.spanArr.forEach((ele, index) => {
         let key = ele.prop
@@ -411,7 +418,7 @@
         })
       })
     },
-    rowSpan (key, parent) {
+    rowSpan(key, parent) {
       let list = [];
       let position = 0;
       this.tableData.forEach((item, index) => {
@@ -435,7 +442,7 @@
       })
       return list
     },
-    spanMethod ({ row, column, rowIndex, columnIndex }) {
+    spanMethod({ row, column, rowIndex, columnIndex }) {
       for (let i = 0; i < this.spanArr.length; i++) {
         const ele = this.spanArr[i]
         if (column.property == ele.prop) {
@@ -453,9 +460,10 @@
 </script>
 
 <style>
-.grid-header {
+/* .grid-header {
   display: none;
-}
+} */
+
 .param-basic {
   margin: 0 10px;
   border-radius: 0px;
@@ -480,30 +488,22 @@
 }
 
 /*鑷畾涔塪isabled鐘舵�佷笅checkbox鐨勬牱寮�*/
-.completeproductstructure-checkout
-  .el-checkbox__input.is-disabled.is-checked
-  .el-checkbox__inner {
+.completeproductstructure-checkout .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
   background-color: #006eff;
   border-color: #006eff;
 }
 
-.completeproductstructure-checkout
-  .el-checkbox__input.is-disabled.is-checked
-  + span.el-checkbox__label {
+.completeproductstructure-checkout .el-checkbox__input.is-disabled.is-checked+span.el-checkbox__label {
   color: #006eff;
   border-color: #006eff;
 }
 
-.completeproductstructure-checkout
-  .el-checkbox__input.is-disabled
-  .el-checkbox__inner {
+.completeproductstructure-checkout .el-checkbox__input.is-disabled .el-checkbox__inner {
   background-color: #ffffff;
   cursor: pointer;
 }
 
-.completeproductstructure-checkout
-  .el-checkbox__input.is-disabled
-  + span.el-checkbox__label {
+.completeproductstructure-checkout .el-checkbox__input.is-disabled+span.el-checkbox__label {
   color: #606266;
   cursor: pointer;
 }
@@ -546,14 +546,23 @@
 .GooFlow .ico .ico_start:before {
   color: red;
 }
+
 .highlight-tab-class {
   color: #006eff;
   background: #e4e7ed;
   border-top: 1px solid #006eff;
 }
+
 .unhighlight-tab-class {
   border: 1px solid #e4e7ed;
   border-bottom: none;
 }
 
+.el-upload-dragger {
+  width: 300px;
+}
+
+.upload-demo {
+  width: 300px;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3