Forráskód Böngészése

提交合同管理的代码

Lijy 9 hónapja
szülő
commit
c36c329de9

+ 197 - 8
fhKeeper/formulahousekeeper/timesheet/src/views/contract/components/customContract.vue

@@ -67,6 +67,7 @@
             <el-link type="primary" :underline="false">{{$t('viewmore')}}<i class="el-icon-arrow-down el-icon--right"></i></el-link>
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item v-if="permissions.contractType" @click.native="typeEdit()"><el-link type="primary" :underline="false" >{{$t('bian-ji') + $t('types')}}</el-link></el-dropdown-item>
+              <el-dropdown-item v-if="permissions.contractType" @click.native="typeEditTwo()"><el-link type="primary" :underline="false" >二级分类</el-link></el-dropdown-item>
               <el-dropdown-item v-if="permissions.contractImport" @click.native="importDialog = true"><el-link type="primary" :underline="false" >{{$t('dao-ru')}}</el-link></el-dropdown-item>
               <el-dropdown-item v-if="permissions.contractExport" @click.native="exportContract()"><el-link type="primary" :underline="false" >{{$t('export.export')}}</el-link></el-dropdown-item>
             </el-dropdown-menu>
@@ -82,7 +83,8 @@
       <el-table-column type="index" width="50"></el-table-column>
       <el-table-column prop="name" :label="$t('he-tong-ming-cheng')" min-width="190"></el-table-column>
       <el-table-column prop="number" :label="$t('contractno')" min-width="190"></el-table-column>
-      <el-table-column prop="typeName" label="合同类别" min-width="190"></el-table-column>
+      <el-table-column prop="typeName" label="合同类型" min-width="190"></el-table-column>
+      <el-table-column prop="secTypeName" label="二级分类" min-width="190"></el-table-column>
       <el-table-column prop="customerOrg" label="对方单位" min-width="190"></el-table-column>
       <el-table-column prop="status" :label="$t('state.states')" min-width="120" align="center">
         <template slot-scope="scope">
@@ -168,10 +170,15 @@
             <el-input v-model="contractForm.name" :disabled="contractForm.status == 0" :maxlength="100" show-word-limit :placeholder="$t('peaseenterthe')" clearable></el-input>
           </el-form-item>
           <el-form-item :label="$t('he-tong-lei-xing')">
-            <el-select v-model="contractForm.typeId" :disabled="contractForm.status == 0" :placeholder="$t('defaultText.pleaseChoose')" style="width:100%">
+            <el-select v-model="contractForm.typeId" :disabled="contractForm.status == 0" :placeholder="$t('defaultText.pleaseChoose')" style="width:100%" @change="selectSecTypeId()">
               <el-option v-for="item in typeList" :key="item.id" :label="item.typeName" :value="item.id"></el-option>
             </el-select>
           </el-form-item>
+          <el-form-item label="二级分类">
+            <el-select v-model="contractForm.secTypeId" :disabled="contractForm.status == 0 || !contractForm.typeId":placeholder="$t('defaultText.pleaseChoose')" style="width:100%" @change="refreshDatas()">
+              <el-option v-for="item in secondaryficationList" :key="item.id" :label="item.secTypeName" :value="item.id"></el-option>
+            </el-select>
+          </el-form-item>
           <!-- <el-form-item :label="$t('schedulestarttime')">
             <el-date-picker
             :disabled="contractForm.status == 0"
@@ -375,6 +382,9 @@
           <el-form-item :label="$t('he-tong-lei-xing')">
             {{contractForm.typeName}}
           </el-form-item>
+          <el-form-item label="二级分类">
+            {{contractForm.secTypeName}}
+          </el-form-item>
           <el-form-item :label="$t('state.states')">
             {{statusList[contractForm.status].label}}
           </el-form-item>
@@ -568,7 +578,43 @@
                 <el-button  @click="denyReasonDialog = false" >{{$t('btn.cancel')}}</el-button>
                 <el-button type="primary" @click="process(null,2)" >{{$t('btn.submit')}}</el-button>
             </div>
-        </el-dialog>
+    </el-dialog>
+
+    <el-dialog title="二级分类" :visible.sync="typeDialogTwo" width="800px" top="7.8vh">
+      <div class="secondaryClassification">
+        <el-tabs v-model="tabsName" tab-position="left" style="height: 100%;" @tab-click="tabClick">
+          <el-tab-pane v-for="(item, index) in typeList" :key="index" :label="item.typeName" :name="item.typeName">
+            <div class="secondaryClassification_content">
+              <el-table :data="secondaryficationList" highlight-current-row v-loading="secondaryLoading" height="50vh" style="width: 100%;flex: 1">
+                <el-table-column type="index" width="60" :label="$t('headerTop.serialNumber')">
+                  <template slot-scope="scope">{{ scope.$index + 1 }}</template>
+                </el-table-column>
+                <el-table-column prop="secTypeName" label="名称"></el-table-column>
+                <el-table-column :label="$t('operation')" width="150">
+                  <template slot-scope="scope">
+                    <el-button size="small" type="primary" @click="editTypeTwoItem(scope.row)">{{$t('bian-ji')}}</el-button>
+                    <el-button size="small" type="danger" @click="typeItemDeleteTwo(scope.row)">{{$t('btn.delete')}}</el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+              <div slot="footer" class="dialog-footer dibucLas">
+                <el-button type="primary" @click="typeDialogTwo = false">{{$t('Shutdown')}}</el-button>
+                <el-button type="primary" @click="editTypeTwoItem()">新增二级分类</el-button>
+              </div>
+              <el-dialog title="新增/编辑分类" :visible.sync="typeTwoItemVisable" append-to-body width="400px">
+                <div style="height: 12vh;overflow-y: auto;overflow-x: hidden;">
+                  <el-input v-model.trim="typeItemForm.typeName" :maxlength="200"></el-input>
+                </div>
+                <div slot="footer" class="dialog-footer;">
+                  <el-button type="primary" @click="typeTwoItemVisable = false">{{$t('btn.cancel')}}</el-button>
+                  <el-button type="primary" @click="typeItemTwoSubmit()">{{$t('btn.determine')}}</el-button>
+                </div>
+              </el-dialog>
+            </div>
+          </el-tab-pane>
+        </el-tabs>
+      </div>
+    </el-dialog>
   </section>
 </template>
 
@@ -615,7 +661,8 @@ export default {
         typeId: null,
         remarks: '',
         startDate: '',
-        endDate: ''
+        endDate: '',
+        secTypeId: ''
       },
       rules:{
         name: [{ required: true, message: this.$t('pleaseentername'), trigger: "blur" }],
@@ -625,11 +672,21 @@ export default {
 
       importDialog: false,
       importLoading: false,
+      typeDialogTwo: false,
       projectList:[],
       page: 1,
       size: 20,
       total: 0,
-      tableHeight: 0
+      tableHeight: 0,
+      typeTwoItemVisable: false,
+      typeItemTwoForm: {
+        typeName: ''
+      },
+      secondaryficationList: [],
+      secondaryficationListTwo: [],
+      secondLevelItem: {},
+      secondaryLoading: false,
+      tabsName: ''
     }
   },
   created() {
@@ -642,8 +699,9 @@ export default {
   },
   mounted() {
     this.getProjectList();
-    this.getContractList()
-    this.getContractType()
+    this.getContractList();
+    this.getContractType();
+    this.getSecondLevelList()
   },
   methods: {
     // test(row){
@@ -827,6 +885,17 @@ export default {
     typeEdit(){
       this.typeDialog = true
     },
+    typeEditTwo() {
+      console.log(this.typeList)
+      console.log(this.secondaryficationList)
+      console.log(this.tabsName)
+      this.secondLevelItem = this.typeList[0] || {}
+      this.tabsName = this.typeList[0] && (this.typeList[0].mainTypeName || this.typeList[0].typeName)
+      const id = this.secondLevelItem.id
+      this.secondaryficationList = this.secondaryficationListTwo.filter(item => item.mainTypeId == id)
+      this.$forceUpdate()
+      this.typeDialogTwo = true
+    },
     typeItemAdd(){
       if(this.typeList.length == 20){
         this.$message({
@@ -923,6 +992,11 @@ export default {
       delete row.customData
       this.dialogTitle = this.$t('bian-ji')
       this.contractForm = JSON.parse(JSON.stringify(row))
+      console.log('开始执行', '<================')
+      if(row.typeId) {
+        const id = row.typeId
+        this.secondaryficationList = this.secondaryficationListTwo.filter(item => item.mainTypeId == id)
+      }
       this.fileList = this.contractForm.files ? this.contractForm.files : []
       for(let i in this.fileList){
         this.fileList[i].name = this.fileList[i].documentName
@@ -1291,7 +1365,105 @@ export default {
           type: 'error'
         })
       })
-    }
+    },
+
+    tabClick(e) {
+      const item = this.typeList[e.index]
+      const { id } = item
+      this.secondLevelItem = item
+      this.secondaryficationList = this.secondaryficationListTwo.filter(item => item.mainTypeId == id)
+    },
+    selectSecTypeId() {
+      this.contractForm.secTypeId = ''
+      const id = this.contractForm.typeId
+      this.secondaryficationList = this.secondaryficationListTwo.filter(item => item.mainTypeId == id)
+    },
+    refreshDatas() {
+      this.$forceUpdate()
+    },
+    editTypeTwoItem(row) {
+      const { id, secTypeName } = row || {};
+      
+      this.typeItemForm = {
+        id: id || undefined,
+        typeName: secTypeName || ''
+      };
+
+      this.typeTwoItemVisable = true;
+    },
+    typeItemDeleteTwo(row) {
+      const { id, secTypeName } = row
+      this.$confirm(`此操作将永久删除【${secTypeName}】, 是否继续?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.postData(`/contract-type-sec/deleteContractType`, {
+            deleteId: id
+          }).then(() => {
+            this.getSecondLevelList()
+            this.$message({
+              type: 'success',
+              message: '删除成功!'
+            })
+          })
+        }).catch(() => {});
+    },
+    getSecondLevelList() {
+      this.secondaryLoading = true
+      this.postData(`/contract-type-sec/getContractType `, {
+
+      }).then(res => {
+        const { id } = this.secondLevelItem
+        this.secondaryficationList = res.data.filter(item => item.mainTypeId == id)
+        this.secondaryficationListTwo = res.data || []
+      }).finally(() => {
+        this.secondaryLoading = false
+      })
+    },
+    typeItemTwoSubmit() {
+      console.log(this.typeItemForm, '<=== 要提交的数据')
+      const mainTypeId = this.secondLevelItem.id
+      const secTypeName = this.typeItemForm.typeName
+      const formVal = {
+        mainTypeId,
+        secTypeName
+      }
+      if(this.typeItemForm.id) {
+        formVal.id = this.typeItemForm.id
+      }
+      this.postData(`/contract-type-sec/changeContractType`, {
+        ...formVal
+      }).then(() => {
+        this.getSecondLevelList()
+        this.typeTwoItemVisable = false
+      })
+    },
+    async postData(urls, param) {
+      return new Promise((resolve, reject) => {
+        this.http.post(urls, { ...param },
+          res => {
+            if(res.code == 'ok') {
+              resolve(res)
+            } else {
+              this.$message({
+                message: res.msg,
+                type: 'error'
+              })
+              reject(res)
+            }
+            resolve(res)
+          },
+          error => {
+            this.$message({
+              message: error,
+              type: "error"
+            });
+            reject(error)
+          }
+        )
+      });
+    },
   },
 }
 </script>
@@ -1331,4 +1503,21 @@ export default {
   line-height: 20px;
   margin-top: 16px;
 }
+
+.secondaryClassification {
+  width: 100%;
+  height: 60vh;
+  overflow: auto;
+}
+.secondaryClassification_content {
+  padding: 10px 20px;
+  display: flex;
+  flex-direction: column;
+  height: 58vh;
+}
+.dibucLas {
+  padding-top: 10px;
+  display: flex;
+  justify-content: flex-end;
+}
 </style>