From 92ff846fb659c62037a32b1d8c15eae9df9d9b54 Mon Sep 17 00:00:00 2001
From: zenglf <18502938215@163.com>
Date: 星期一, 18 九月 2023 13:24:30 +0800
Subject: [PATCH] Merge branch 'develop' of http://117.34.109.166:18448/r/vue_mdc_430

---
 src/views/eam/modules/dailyMaintenanceStandard/MaintenanceStandardWorkInstructionModal.vue |  351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 351 insertions(+), 0 deletions(-)

diff --git a/src/views/eam/modules/dailyMaintenanceStandard/MaintenanceStandardWorkInstructionModal.vue b/src/views/eam/modules/dailyMaintenanceStandard/MaintenanceStandardWorkInstructionModal.vue
new file mode 100644
index 0000000..31a61aa
--- /dev/null
+++ b/src/views/eam/modules/dailyMaintenanceStandard/MaintenanceStandardWorkInstructionModal.vue
@@ -0,0 +1,351 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="850"
+    :visible="visible"
+    :maskClosable="false"
+    :confirmLoading="confirmLoading"
+    :okButtonProps="{ props: {disabled: disableSubmit} }"
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="鍏抽棴"
+  >
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{span:4}"
+              :wrapperCol="{span:18}"
+              label="鏂囨。缂栫爜"
+            >
+              <a-input
+                :disabled="disableSubmit"
+                placeholder="璇疯緭鍏ユ枃妗g紪鐮�"
+                v-decorator="['num', validatorRules.num ]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{span:4}"
+              :wrapperCol="{span:18}"
+              label="鏂囦欢绫诲瀷"
+            >
+              <j-dict-select-tag
+                allow-clear
+                placeholder="璇烽�夋嫨鏂囨。绫诲瀷"
+                :triggerChange="true"
+                dictCode="mom_eam_document_type,name,id, del_flag!='1'"
+                v-decorator="['fileType', validatorRules.fileType ]"
+              />
+              <!-- <a-radio-group
+                v-for="(item,index) in fileTypes"
+                :key="index"
+                button-style="solid"
+                v-decorator="['fileType', validatorRules.fileType ]"
+                :disabled="disableSubmit"
+              >
+
+                <a-radio-button :value="item.value">
+                  {{item.text}}
+                </a-radio-button>
+              </a-radio-group> -->
+
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{span:4}"
+              :wrapperCol="{span:18}"
+              label="鏂囦欢涓婁紶"
+            >
+              <a-upload-dragger
+                name="file"
+                :customRequest="customRequest"
+                @change="handleChange"
+                :file-list="fileList"
+                :multiple="false"
+              >
+                <p class="ant-upload-drag-icon">
+                  <a-icon type="inbox" />
+                </p>
+                <p class="ant-upload-text">
+                  鐐瑰嚮涓婁紶鎴栨嫋鎷芥枃浠惰嚦璇ュ尯鍩熻繘琛屼笂浼�
+                </p>
+                <p class="ant-upload-hint">
+                  浠呮敮鎸佸崟鏂囦欢涓婁紶
+                </p>
+              </a-upload-dragger>
+            </a-form-item>
+          </a-col>
+        </a-row>
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{span:4}"
+              :wrapperCol="{span:18}"
+              label="鏂囦欢鍚嶇О"
+            >
+              <a-input
+                :disabled="true "
+                placeholder="璇疯緭鍏ユ枃浠跺悕绉�"
+                v-decorator="['name', validatorRules.name ]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+
+        <a-row :gutter="24">
+          <a-col :span="24">
+            <a-form-item
+              :labelCol="{span:4}"
+              :wrapperCol="{span:18}"
+              label="鏂囦欢鎻忚堪"
+            >
+              <a-textarea
+                :disabled="disableSubmit"
+                placeholder="璇疯緭鍏ユ枃浠舵弿杩�"
+                allow-clear
+                v-decorator="['description', validatorRules.description]"
+              />
+            </a-form-item>
+          </a-col>
+        </a-row>
+
+      </a-form>
+    </a-spin>
+  </a-modal>
+</template>
+ 
+<script>
+import { getAction, postAction, postFileAction } from '@/api/manage'
+import Vue from 'vue'
+import JInput from '@/components/jeecg/JInput'
+import Tooltip from 'ant-design-vue/es/tooltip'
+import JEllipsis from "@/components/jeecg/JEllipsis";
+import { ajaxGetDictItems } from '@/api/api'
+import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
+
+export default {
+  name: "UploadModel",
+  components: {
+    JInput,
+    Tooltip,
+    JEllipsis,
+  },
+  data() {
+    return {
+      title: "鎿嶄綔",
+      visible: false,
+      disableSubmit: false,
+      model: {},
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 8 },
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 },
+      },
+      confirmLoading: false,
+      form: this.$form.createForm(this),
+      headers: {},
+      validatorRules: {
+        num: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ョ紪鐮侊紒' },
+            { min: 0, max: 150, message: '鏈�闀� 30 涓瓧绗�', trigger: 'blur' },
+          ]
+        },
+        fileType: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ラ�夋嫨绫诲瀷锛�' },
+          ]
+        },
+        name: {
+          rules: [
+            { required: true, message: '璇疯緭鍏ュ悕绉帮紒' },
+          ]
+        },
+      },
+      url: {
+        add: "/eam/maintenanceStandardWorkInstruction/add",
+        edit: "/eam/maintenanceStandardWorkInstruction/edit",
+        listByBusIdAndBusType: "/system/sysUploadRela/listByBusIdAndBusType",
+      },
+      //鐢ㄤ簬灞曠ず鏂囦欢
+      fileList: [],
+      fileObject: {},
+      fileTypes: [],
+      //鐢ㄤ簬鍒ゆ柇闄勪欢鐨勭姸鎬�  add锛氭柊澧為〉闈㈢殑闄勪欢  edit锛氱紪杈戦〉闈㈢殑闄勪欢涓鸿淇敼i   editUpdate锛氱紪杈戦〉闈㈢殑闄勪欢琚慨鏀�
+      isFileChange: false,
+      uploadId: '',
+      maintenanceStandardId: '',
+    }
+  },
+
+  methods: {
+    customRequest(val) {
+      if (this.fileList.length == 0) {
+        this.fileObject = val;
+      }
+    },
+
+    handleChange(info) {
+      //榛樿缁欓檮浠剁姸鎬侊紝浠呮帶鍒舵牱寮�
+      let file = info.file;
+      //鏂囦欢鏇存敼锛屾爣璁版洿鏂�
+      if (this.model.id) {
+        this.isFileChange = true;
+      }
+      //鍒犻櫎
+      if (file.status == "removed") {
+        this.fileList = [];
+        this.fileObject.file = {};
+        this.form.setFieldsValue({ name: '' });
+        return false;
+      }
+      //鍗曟枃浠舵帶鍒�
+      if (this.fileList.length > 0) {
+        this.$message.warning("褰撳墠浠呭厑璁镐笂浼犱竴涓枃浠讹紒");
+        return false;
+      }
+      file.status = 'done';
+      //椤甸潰灞曠ず涓婁紶鏂囦欢
+      this.fileList.push(file);
+      this.form.setFieldsValue({ name: file.name });
+    },
+
+    add() {
+      this.edit({})
+    },
+
+    edit(record) {
+      let that = this;
+      that.visible = true;
+      that.isFileChange = false;
+      that.model = Object.assign({}, record);
+      that.fileList = [];
+      that.form.resetFields();
+      that.uploadId = ''
+      if (record.isNoPhotoFlag) {
+        //鑾峰彇褰撳墠鏂囦欢瀵瑰簲闄勪欢
+        getAction(that.url.listByBusIdAndBusType, { busId: record.id, busType: 'maintenance_standard_work_instruction' }).then((res) => {
+          if (res.success) {
+            for (let i = 0; i < res.result.length; i++) {
+              that.fileList.push({
+                uid: res.result[i].upload.id,
+                name: res.result[i].upload.name,
+                status: "done",
+              })
+              that.$nextTick(() => {
+                that.form.setFieldsValue({ name: res.result[i].upload.name });
+              });
+            }
+          }
+        })
+      }
+    },
+
+    close() {
+      this.$emit('close');
+      this.visible = false;
+    },
+
+    handleOk() {
+      const that = this;
+      // 瑙﹀彂琛ㄥ崟楠岃瘉
+      that.form.validateFields((err, values) => {
+        if (JSON.stringify(that.fileObject.file) == '{}' && that.uploadId == '' && that.fileList.length == 0) {
+          that.$message.warning("璇蜂笂浼犳枃浠�");
+          return false
+        }
+        if (!err) {
+          that.confirmLoading = true;
+          let httpurl = ''
+          let method = ''
+          if (!that.model.id) {
+            httpurl += that.url.add;
+            method = 'post';
+          } else {
+            httpurl += that.url.edit;
+            method = 'put';
+          }
+          let formData = Object.assign(that.model, values);
+
+          formData.type = "maintenance_standard_work_instruction";
+          formData.uploadId = that.uploadId;
+          // formData.fileType = "7";//鏂囦欢绫诲瀷  7锛氬浘鐗�
+          formData.maintenanceStandardId = this.maintenanceStandardId;
+          var saveDate = new FormData();
+
+          formData.isFileChange = that.isFileChange;
+
+          saveDate.append("file", that.fileObject.file);
+          saveDate.append('data', JSON.stringify(formData));
+
+          postFileAction(httpurl, saveDate, this.headers).then((res) => {
+            if (res.success) {
+              that.$message.success(res.message);
+              that.$emit('ok');
+            } else {
+              that.$message.warning(res.message);
+            }
+          }).finally(() => {
+            that.confirmLoading = false;
+            that.close();
+          })
+        }
+      }).catch((e) => { })
+    },
+
+    handleCancel() {
+      this.close();
+    },
+    // initFileTypes() {
+    //   ajaxGetDictItems("common_upload_type", null).then((res) => {
+    //     if (res.success) {
+    //       this.fileTypes = res.result;
+    //     }
+    //   })
+    // },
+
+  },
+
+  created() {
+    // this.initFileTypes();
+    const token = Vue.ls.get(ACCESS_TOKEN);
+    const tenantid = Vue.ls.get(TENANT_ID)
+    this.headers = {
+      'Content-Type': 'multipart/form-data',
+      "X-Access-Token": token,
+      'X-Access-Tenant': tenantid
+    };
+  },
+}
+</script>
+<style scoped>
+.ant-btn {
+  padding: 0 10px;
+  margin-left: 3px;
+}
+
+.ant-form-item-control {
+  line-height: 0px;
+}
+
+/** 涓昏〃鍗曡闂磋窛 */
+.ant-form .ant-form-item {
+  margin-bottom: 10px;
+}
+
+/** Tab椤甸潰琛岄棿璺� */
+.ant-tabs-content .ant-form-item {
+  margin-bottom: 0px;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3