研发图纸文件管理系统-前端项目
he wei
2022-08-24 1880a8510955ee429e768b43cc8bf32cbb13acb3
U 产品列表 上传产品
1个文件已修改
1个文件已添加
224 ■■■■■ 已修改文件
src/pages/resourceManage/product/list.vue 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/product/prodUpload.vue 202 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/product/list.vue
@@ -32,6 +32,9 @@
          >
            <template slot="title">
              <span class="title">产品中心</span>
              <a-space class="operator" style="margin-left: 1em">
                  <a-button type="primary" @click="uploadProd">新增</a-button>
              </a-space>
            </template>
            <template slot="action" slot-scope="{ record }">
              <a @click="upload(record)">上传软件</a>
@@ -145,12 +148,25 @@
    >
      <change-parts :parent-data="editObj" @close="cancel"></change-parts>
    </a-modal>
    <!-- 上传Bom -->
    <a-modal
      :visible="prodUploadShow"
      :footer="null"
      :width="500"
      title="上传产品BOM"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="prodUploadCancel"
    >
      <prod-upload></prod-upload>
    </a-modal>
  </div>
</template>
<script>
import AdvanceTable from "@/components/table/advance/AdvanceTable";
import ChangeParts from "./changeParts";
import ProdUpload from './prodUpload';
import getWebUrl from "@/assets/js/tools/getWebUrl";
import { getList, downloadBom } from "./apis";
@@ -165,6 +181,7 @@
  mixins: [WSMixin],
  data() {
    return {
      prodUploadShow: false,
      info: {
        nextUser: "",
        description: "",
@@ -260,6 +277,7 @@
  components: {
    AdvanceTable,
    ChangeParts,
    ProdUpload
  },
  methods: {
    onSearch(conditions, searchOptions) {
@@ -448,6 +466,10 @@
        this.userList = this.projectManagerList.map((item) => item);
      }
    },
    // 新增产品 bom导入
    uploadProd() {
      this.prodUploadShow = true;
    }
  },
  watch: {
    update(n) {
src/pages/resourceManage/product/prodUpload.vue
New file
@@ -0,0 +1,202 @@
<template>
  <div class="">
    <a-row class="title">
      <a-col :span="6" class="text-right">
        <span>产品信息</span>
      </a-col>
      <a-col :span="15" :offset="1">
        <div class="lab">
          母件编码: 123456
          母件名称:123
          母件型号:456
          定制单号:无
        </div>
      </a-col>
    </a-row>
    <a-row class="upload">
      <a-col :span="15" :offset="7">
        <a-upload
          :before-upload="beforeUpload"
          @change="uploadChange"
          accept=".zip"
        >
          <a-button type="primary">上传软件</a-button>
        </a-upload>
      </a-col>
    </a-row>
    <a-form-model
      ref="formRef"
      name="advanced_search"
      class="ant-advanced-search-form"
      :model="info"
      :rules="rules"
    >
      <a-row>
        <a-col :span="24">
          <a-form-model-item
            label="审核人"
            :labelCol="{ span: 6 }"
            :wrapperCol="{ span: 15, offset: 1 }"
            prop="nextUser"
          >
            <a-select
              show-search
              v-model="info.nextUser"
              placeholder="请选择审核人"
            >
              <a-select-option
                v-for="(item, key) in userList"
                :key="'key' + key"
                :value="item.id"
                :title="item.name"
              >
                {{ item.name }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item
            label="工单描述"
            :labelCol="{ span: 6 }"
            :wrapperCol="{ span: 15, offset: 1 }"
            prop="description"
          >
            <a-textarea
              placeholder="请输入工单描述"
              v-model="info.description"
              :rows="4"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <div class="modal-footer">
      <a-button type="danger" @click="uploadCancel"> 取消 </a-button>
      <a-button type="primary" @click="uploadCancel"> 提交审核 </a-button>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  name: "",
  data() {
    return {
      userList: [],
      file: null,
      info: {
        nextUser: "",
        description: "",
      },
      rules: {
        nextUser: [
          {
            required: true,
            message: "请选择审核人",
            trigger: "blur",
          },
        ],
      },
    };
  },
  components: {
    ...mapGetters("account", [
      "roles",
      "projectManagerList",
      "generalManagerList",
    ]),
  },
  methods: {
    getUserByRoleId() {
      if (this.roles[0].id == 1002) {
        this.userList = this.generalManagerList.map((item) => item);
      } else {
        this.userList = this.projectManagerList.map((item) => item);
      }
    },
    beforeUpload() {
      return false;
    },
    uploadCancel() {
      this.uploadShow = false;
    },
    uploadSoftware() {
      let obj = {
        approving: {
          parentModel: this.prodData.parentModel,
        },
        main: {
          nextUser: this.info.nextUser,
          title: `为产品${this.prodData.parentModel}上传软件`,
          description: this.info.description,
        },
      };
      if (!this.file) {
        this.$message.warning("请选择要上传的软件包");
        return false;
      }
      this.$refs.formRef.validate((valid) => {
        if (!valid) {
          this.$message.error("存在未通过检验的表单项");
          return false;
        } else {
          const formData = new FormData();
          formData.append("multipartFile", this.file);
          formData.append("mainDTOString", JSON.stringify(obj));
          // productSoftwareSubmit(formData)
          //   .then((res) => {
          //     // this.$layer.close(loadinobjobj
          //     let rs = res.data;
          //     if (rs.code == 1 && rs.data) {
          //       this.resList = rs.data2;
          //       this.title = rs.data3;
          //       this.resShow = true;
          //       this.$message.success(rs.msg);
          //     } else {
          //       this.$message.error(rs.msg);
          //     }
          //   })
          //   .catch((error) => {
          //     // this.$layer.close(loading);
          //     console.log(error);
          //   });
        }
      });
    },
    upload(record) {
      this.prodData = record;
      this.uploadShow = true;
    },
    uploadChange(data) {
      const { file, fileList } = data;
      if (fileList.length > 1) {
        fileList.shift();
        // console.log(file, fileList, "90909090");
      }
      if (fileList.length) {
        // this.file = fileList[0];
        // console.log(file == fileList[0], file == fileList[0].originFileObj)
        this.file = fileList[0].originFileObj;
      } else {
        this.file = null;
      }
    },
  },
  mounted() {
    this.getUserByRoleId();
  },
};
</script>
<style lang="less" scoped>
.modal-footer {
  text-align: right;
  button + button {
    margin-left: 8px;
  }
}
</style>