From 7d0a954d23d21c0cdaff6ed20ad7291b3dbf889a Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 30 六月 2022 17:45:39 +0800
Subject: [PATCH] 1.完成制造模型(工序定义)页面开发

---
 src/views/xtsz/bmgz.vue |  153 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 93 insertions(+), 60 deletions(-)

diff --git a/src/views/xtsz/bmgz.vue b/src/views/xtsz/bmgz.vue
index f6517c7..2e6270d 100644
--- a/src/views/xtsz/bmgz.vue
+++ b/src/views/xtsz/bmgz.vue
@@ -68,7 +68,7 @@
           />
           <el-table-column
             prop="prefix"
-            label="鍓嶇紑"
+            label="鍥哄畾瀛楃"
             sortable="custom"
           >
             <template slot-scope="{row}">
@@ -132,12 +132,12 @@
     >
       <el-form ref="dialogForm" :rules="dialogFormRules" :model="dialogForm" label-width="80px">
 
-        <el-form-item label="鍥哄畾瀛楃" prop="OrgName">
-          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
+        <el-form-item label="鍥哄畾瀛楃" prop="prefix">
+          <el-input v-model="dialogForm.prefix" style="width: 220px" />
         </el-form-item>
-        <el-form-item prop="SupUnit" label="鎻愪氦鏃ユ湡">
+        <el-form-item prop="filingdate" label="鎻愪氦鏃ユ湡">
           <el-select
-            v-model="dialogForm.SupUnit"
+            v-model="dialogForm.filingdate"
             style="width: 220px"
             placeholder="璇烽�夋嫨"
             :popper-append-to-body="false"
@@ -150,12 +150,14 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item label="鑷浣嶆暟" prop="OrgName">
-          <el-input v-model="dialogForm.OrgName" style="width: 220px" />
+        <el-form-item label="鑷浣嶆暟" prop="incbit">
+          <!--          @change="handleChange"-->
+          <el-input-number v-model="dialogForm.incbit" :min="1" :max="100" label="鎻忚堪鏂囧瓧" />
+
+          <!--          <el-input v-model="dialogForm.incbit" style="width: 220px" />-->
         </el-form-item>
         <el-form-item label="缂栫爜棰勮">
-          <!--          <el-input v-model="dialogForm.OrgName" style="width: 220px" />-->
-          xxxx
+          {{ encodingPre }}
         </el-form-item>
       </el-form>
 
@@ -171,9 +173,7 @@
 
 <script>
 import Pagination from '@/components/Pagination'
-import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
-import { getCookie } from '@/utils/auth'
-import { EncodingRules } from '@/api/xtsz'
+import { EncodingRules, SaveEncodingRules } from '@/api/xtsz'
 
 const SER_HZ = /^[\u4e00-\u9fa5]+$/
 export default {
@@ -205,30 +205,50 @@
         rows: 20 // 姣忛〉澶氬皯鏉�
       },
       dateType: [
-        { label: '骞�', value: 'Y' },
-        { label: '鏈�', value: 'M' },
-        { label: '鏃�', value: 'D' }
+        { label: '骞存湀鏃�', value: 'YMD' },
+        { label: '骞存湀', value: 'YM' },
+        { label: '骞�', value: 'Y' }
       ],
 
       total: 10,
       tableData: [],
       dialogVisible: false,
       dialogForm: {
-        OrgType: '',
-        OrgCode: '',
-        OrgName: '',
-        SupUnit: ''// 涓婄骇鍗曚綅
+        rightcode: '', // 鍔熻兘缂栫爜
+        rightname: '', // 鍔熻兘鍚嶇О
+        prefix: '', // 鍥哄畾瀛楃
+        filingdate: '', // 鎻愪氦鏃ユ湡
+        incbit: '' // 鑷浣嶆暟
       },
       operation: '',
+      encodingPre: '', // 缂栫爜棰勮
       dialogFormRules: {
         // OrgCode: [
         //   { required: true, validator: validateName, trigger: ['blur', 'change'] }
         // ],
-        OrgName: [
-          { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: ['blur', 'change'] }
-        ]
+        // OrgName: [
+        //   { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: ['blur', 'change'] }
+        // ]
       }
 
+    }
+  },
+  watch: {
+    dialogForm: {
+      handler(newVlaue, oldValue) {
+        const date = new Date()
+        let newDate = ''
+        if (newVlaue.filingdate === 'YMD') {
+          newDate = date.getFullYear() + '' + (date.getMonth() + 1 + '').padStart(2, '0') + '' + (date.getDate() + '').padStart(2, '0')
+        } else if (newVlaue.filingdate === 'YM') {
+          newDate = date.getFullYear() + '' + (date.getMonth() + 1 + '').padStart(2, '0')
+        } else if (newVlaue.filingdate === 'Y') {
+          newDate = date.getFullYear() + ''
+        }
+        this.encodingPre = newVlaue.prefix + '' + newDate + '' + (1 + '').padStart(newVlaue.incbit, '0')
+      },
+      immediate: true,
+      deep: true
     }
   },
   created() {
@@ -243,10 +263,6 @@
       const res = await EncodingRules(this.form)
       this.tableData = res.data
       this.total = res.count
-      // this.tableData = [
-      //   { code: 123, name: 'xxx1' }
-      // ]
-      // this.total = 10
     },
     // 鎺掑簭鏀瑰彉鏃�
     sortChange({ column, prop, order }) {
@@ -270,10 +286,8 @@
     },
     // 閲嶇疆
     reset() {
-      this.form.OrgCode = ''
-      this.form.OrgName = ''
-      this.form.OrgType = ''
-      this.form.UserName = ''
+      this.form.rightname = ''
+      this.form.prefix = ''
       this.getEncodingRules()
     },
 
@@ -288,34 +302,37 @@
       this.dialogVisible = true
 
       this.$nextTick(() => {
-        this.dialogForm.OrgCode = row.org_code
-        this.dialogForm.OrgName = row.org_name
-        this.dialogForm.SupUnit = row.parent_id
+        this.dialogForm.rightcode = row.right_code
+        this.dialogForm.rightname = row.right_name
+        this.dialogForm.filingdate = this.dateType.find(item => item.label === row.filingdate).value
+        this.dialogForm.incbit = row.incbit
+        this.dialogForm.prefix = row.prefix
       })
     },
     // 鍒犻櫎鎸夐挳
     async del(row) {
-      this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
-        confirmButtonText: '纭畾',
-        cancelButtonText: '鍙栨秷',
-        type: 'warning'
-      }).then(() => {
-        DeleteOrganization({ orgid: row.code }).then(res => {
-          if (res.code === '200') {
-            this.$message.success('鍒犻櫎鎴愬姛!')
-            this.getEncodingRules()
-          }
-        })
-      }).catch(() => {
-        this.$message.info('宸插彇娑堝垹闄�')
-      })
+      // this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+      //   confirmButtonText: '纭畾',
+      //   cancelButtonText: '鍙栨秷',
+      //   type: 'warning'
+      // }).then(() => {
+      //   DeleteOrganization({ orgid: row.code }).then(res => {
+      //     if (res.code === '200') {
+      //       this.$message.success('鍒犻櫎鎴愬姛!')
+      //       this.getEncodingRules()
+      //     }
+      //   })
+      // }).catch(() => {
+      //   this.$message.info('宸插彇娑堝垹闄�')
+      // })
     },
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
-      this.dialogForm.OrgType = ''
-      this.dialogForm.OrgCode = ''
-      this.dialogForm.OrgName = ''
-      this.dialogForm.SupUnit = ''
+      this.dialogForm.rightcode = ''
+      this.dialogForm.rightname = ''
+      this.dialogForm.filingdate = ''
+      this.dialogForm.incbit = ''
+      this.dialogForm.prefix = ''
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -327,12 +344,15 @@
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
           const data = {
-            OrganCode: this.dialogForm.OrgCode,
-            OrganName: this.dialogForm.OrgName,
-            OperType: this.operation === 'add' ? 'Add' : 'Update',
-            Operator: getCookie('admin')
+            rightcode: this.dialogForm.rightcode,
+            rightname: this.dialogForm.rightname,
+            incbit: this.dialogForm.incbit,
+            // filingdate: this.dialogForm.filingdate,
+            filingdate: this.dateType.find(item => item.value === this.dialogForm.filingdate).label,
+            prefix: this.dialogForm.prefix
           }
-          AddUpdateOrganization(data).then(res => {
+          console.log(data)
+          SaveEncodingRules(data).then(res => {
             if (res.code === '200') {
               this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.dialogVisible = false
@@ -366,9 +386,11 @@
   border: none;
   padding: 0 20px;
 }
+
 ::v-deep .el-button--primary:hover {
   border: none;
 }
+
 ::v-deep .el-button--info {
   height: 30px;
   display: flex;
@@ -424,6 +446,7 @@
   height: 30px;
   line-height: 30px;
 }
+
 ::v-deep .el-input__inner:focus {
   border-color: $main_color;
 }
@@ -500,18 +523,28 @@
   border-color: $main_color;
 }
 
-::v-deep .el-select .el-input__inner:focus{
+::v-deep .el-select .el-input__inner:focus {
   border-color: $main_color;
 }
 
-::v-deep .el-select-dropdown__item.selected{
+::v-deep .el-select-dropdown__item.selected {
   color: $main_color;
 }
-::v-deep .el-checkbox__inner:hover{
+
+::v-deep .el-checkbox__inner:hover {
   border-color: $main_color;
 }
-::v-deep .el-textarea__inner:focus{
+
+::v-deep .el-textarea__inner:focus {
   border-color: $main_color;
 }
 
+::v-deep .el-input-number__decrease,::v-deep .el-input-number__increase {
+  background-color: $main_color;
+  color: #FFFFFF;
+  line-height: 31px;
+  height: 31px;
+  margin-top: 3px;
+}
+
 </style>

--
Gitblit v1.9.3