Jelajahi Sumber

feat: 更新证件有效期选择逻辑

将日期范围选择器改为独立的开始和结束时间选择器,并替换供应商和客户选择组件
yusheng 3 bulan lalu
induk
melakukan
509de2945c

+ 6 - 6
src/public-path.js

@@ -1,11 +1,11 @@
 (function () {
   if (window.__POWERED_BY_QIANKUN__) {
-    if (process.env.NODE_ENV === 'development') {
-      // eslint-disable-next-line
-      __webpack_public_path__ = `//localhost:${process.env.VUE_APP_PORT}/`;
-      console.log('__webpack_public_path__', __webpack_public_path__);
-      return;
-    }
+    // if (process.env.NODE_ENV === 'development') {
+    //   // eslint-disable-next-line
+    //   __webpack_public_path__ = `//localhost:${process.env.VUE_APP_PORT}/`;
+    //   console.log('__webpack_public_path__', __webpack_public_path__);
+    //   return;
+    // }
     // eslint-disable-next-line
     __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
     // __webpack_public_path__ = `${process.env.BASE_URL}/`

+ 79 - 22
src/views/documentManagement/certificateManagement/components/add-dialog.vue

@@ -103,8 +103,29 @@
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
-          <el-form-item prop="date" label="有效期至">
-            <el-date-picker
+          <el-form-item prop="validityStartTime" label="有效期至">
+            <div style="display: flex">
+              <el-date-picker
+                style="flex: 1"
+                v-model="form.validityStartTime"
+                type="date"
+                value-format="yyyy-MM-dd HH:mm:ss"
+                placeholder="选择日期"
+                @change="handleTimeChange('validityStartTime')"
+              >
+              </el-date-picker>
+              <div style="width: 40px; text-align: center">至</div>
+              <el-date-picker
+                style="flex: 1"
+                v-model="form.validityEndTime"
+                type="date"
+                value-format="yyyy-MM-dd HH:mm:ss"
+                placeholder="选择日期"
+                @change="handleTimeChange('validityEndTime')"
+              >
+              </el-date-picker>
+            </div>
+            <!-- <el-date-picker
               style="width: 100%"
               v-model="form.date"
               type="daterange"
@@ -114,7 +135,7 @@
               value-format="yyyy-MM-dd HH:mm:ss"
               :default-time="['00:00:00', '23:59:59']"
             >
-            </el-date-picker>
+            </el-date-picker> -->
           </el-form-item>
         </el-col>
         <el-col v-bind="styleResponsive ? { sm: 24 } : { span: 24 }">
@@ -140,14 +161,23 @@
       @confirm="confirmStaffSelection"
     ></staffSelection>
     <productTable ref="productTableRef" />
-    <supplierSelection
+
+    <vendorDialog
+      ref="supplierSelectionRef"
+      @success="confirmStaffSelection1"
+    ></vendorDialog>
+    <clientDialog
+      ref="customerSelectionRef"
+      @success="confirmStaffSelection1"
+    ></clientDialog>
+    <!-- <supplierSelection
       ref="supplierSelectionRef"
       @confirm="confirmStaffSelection"
     />
     <customerSelection
       ref="customerSelectionRef"
       @confirm="confirmStaffSelection"
-    />
+    /> -->
     <div slot="footer" class="dialog-footer">
       <el-button size="small" @click="save" type="primary">保 存</el-button>
       <el-button size="small" @click="close">关 闭</el-button>
@@ -158,12 +188,13 @@
 <script>
   import staffSelection from './staffSelection.vue';
   import { saveOrEdit, getPhotoInfo } from '@/api/documentManagement';
-  // import fileMain from '@/components/addDoc/index.vue';
+  import clientDialog from '@/views/factoryModel/qualificationManagement/components/clientDialog.vue';
+  import vendorDialog from '@/views/factoryModel/qualificationManagement/components/vendorDialog.vue';
 
   import { getCode } from '@/api/ruleManagement/matter';
   import productTable from './productTable.vue';
-  import supplierSelection from './supplierSelection.vue';
-  import customerSelection from './customerSelection.vue';
+  // import supplierSelection from './supplierSelection.vue';
+  // import customerSelection from './customerSelection.vue';
   import { listOrganizations } from '@/api/system/organization';
   import { holderTypeOptions } from '@/enum/dict.js';
   const defaultForm = {
@@ -180,8 +211,8 @@
     components: {
       staffSelection,
       productTable,
-      supplierSelection,
-      customerSelection,
+      vendorDialog,
+      clientDialog
       // fileMain
     },
     //注册组件
@@ -210,9 +241,20 @@
           type: [
             { required: true, trigger: 'change', message: '请选择证件类型' }
           ],
-          // date: [
-          //   { required: true, trigger: 'change', message: '请选择有效期' }
-          // ],
+          validityStartTime: [
+            {
+              required: true,
+              trigger: 'change',
+              message: '请选择有效期开始时间'
+            }
+          ],
+          validityEndTime: [
+            {
+              required: true,
+              trigger: 'change',
+              message: '请选择有效期结束时间'
+            }
+          ],
           holder: [
             { required: true, trigger: 'change', message: '请选择持证对象' }
           ],
@@ -242,13 +284,16 @@
       },
       //选择负责人
       confirmStaffSelection(data) {
-        console.log(data);
         this.form.holderId = data.map((item) => item.id).join(',');
 
         this.form.holder = data.map((item) => item.name).join(',');
         this.$forceUpdate();
         console.log(this.form);
       },
+      confirmStaffSelection1(data) {
+        this.form.holderId = data.id;
+        this.form.holder = data.name;
+      },
       openStaffSelection() {
         if (this.form.holderType == 1) {
           this.$refs.staffSelection.open([]);
@@ -274,12 +319,12 @@
       },
 
       async getInfo(id) {
-        const data = await getPhotoInfo(id);        
+        const data = await getPhotoInfo(id);
         this.form = {
           ...data,
-          date: [data.validityStartTime, data.validityEndTime],
+          // date: [data.validityStartTime, data.validityEndTime],
           holderType: data.holderType || '1',
-          type: data.holderType === '1' ? data.type : data.type + '',
+          type: data.holderType === '1' ? data.type : data.type + ''
         };
         this.$refs.productTableRef.putTableValue(data.categorys || []);
       },
@@ -290,6 +335,18 @@
         this.form = { ...defaultForm };
         this.$refs.productTableRef.initData();
       },
+      handleTimeChange(key) {
+        if (this.form.validityStartTime && this.form.validityEndTime) {
+          if (this.form.validityStartTime > this.form.validityEndTime) {
+            this.$message.error(
+              `${key == 'validityStartTime' ? '开始' : '结束'}时间不能${
+                key == 'validityStartTime' ? '大于' : '小于'
+              }${key == 'validityStartTime' ? '结束' : '开始'}时间`
+            );
+            this.form[key] = '';
+          }
+        }
+      },
 
       save() {
         this.$refs.form.validate((valid) => {
@@ -297,15 +354,15 @@
             return false;
           }
           this.loading = true;
-          if (this.form.date?.length) {
-            this.form.validityStartTime = this.form.date[0];
-            this.form.validityEndTime = this.form.date[1];
-          }
+          // if (this.form.date?.length) {
+          //   this.form.validityStartTime = this.form.date[0];
+          //   this.form.validityEndTime = this.form.date[1];
+          // }
 
           const data = {
             ...this.form
           };
-          delete data.date;
+          // delete data.date;
           let productTable = this.$refs.productTableRef.getTableValue();
           data.categorys = productTable || [];
           saveOrEdit(data)

+ 1 - 1
src/views/material/product/index.vue

@@ -2,7 +2,7 @@
   <div class="ele-body">
     <el-card shadow="never">
       <ele-split-layout
-        width="300px"
+        width="260px"
         allow-collapse
         :right-style="{ overflow: 'hidden' }"
       >