懒羊羊
2024-01-04 5b805a057ebc3fb7dd18fc26ff152f768b5b74e6
优化
已修改1个文件
73 ■■■■■ 文件已修改
jcdm-ui/src/views/main/bs/processFile/index.vue 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-ui/src/views/main/bs/processFile/index.vue
@@ -97,7 +97,10 @@
          </el-table-column>
          <el-table-column label="文件名称" align="center" prop="fileName">
          </el-table-column>
          <el-table-column label="文件地址" align="center" prop="fileAddress">
          <el-table-column :show-overflow-tooltip='true' width="150" label="文件地址" align="center" prop="fileAddress">
            <template slot-scope="scope">
              <a :href="scope.row.fileAddress" target="_blank" style="color: #00afff" class="buttonText">{{scope.row.fileAddress}}</a>
            </template>
          </el-table-column>
          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
@@ -110,7 +113,7 @@
<!--          </el-table-column>-->
          <el-table-column label="备注" align="center" prop="remarks">
          </el-table-column>
          <el-table-column fixed="right" width="200" label="操作" align="center" class-name="small-padding fixed-width">
          <el-table-column fixed="right" width="300" label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
@@ -130,6 +133,14 @@
                @click="handleDelete(scope.row)"
                v-hasPermi="['bs:processFile:remove']"
              >删除</el-button>
              <el-button
                size="mini"
                plain
                type="warning"
                style="width: 72px"
                icon="el-icon-download"
                @click="handleDownload(scope.row)"
              >下载</el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -182,8 +193,23 @@
          <el-input v-model="form.fileName" placeholder="请输入文件名称" />
        </el-form-item>
        <el-form-item label="文件地址" prop="fileAddress">
          <el-input v-model="form.fileAddress" placeholder="请输入文件地址" />
<!--          <el-input v-model="form.fileAddress" placeholder="请输入文件地址" />-->
          <el-upload
            ref="upload"
            :limit="1"
            accept=".doc, .docx"
            :action="upload.url"
            :headers="upload.headers"
            :file-list="upload.fileList"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :auto-upload="false">
            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            <el-button style="margin-left: 10px;" size="small" type="success" :loading="upload.isUploading" @click="submitUpload">上传到服务器</el-button>
            <div slot="tip" class="el-upload__tip">只能上传doc/docx文件,且不超过10MB</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio
@@ -206,6 +232,7 @@
</template>
<script>
import { getToken } from "@/utils/auth";
import { listProcessFile, getProcessFile, delProcessFile, addProcessFile, updateProcessFile } from "@/api/main/bs/processFile/processFile";
import {listProductBom} from "@/api/main/bs/ProductBom/ProductBom";
import {listProcesses} from "@/api/main/bs/processes/processes";
@@ -219,6 +246,17 @@
  dicts: ['sys_normal_disable'],
  data() {
    return {
      // 上传参数
      upload: {
        // 是否禁用上传
        isUploading: false,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/common/upload",
        // 上传的文件列表
        fileList: []
      },
      // 遮罩层
      loading: true,
      titleName: "",
@@ -293,7 +331,32 @@
    this.initProcesses();
  },
  methods: {
    // 文件下载处理
    handleDownload(row) {
      console.log(row)
      var name = row.fileName;
      var url = row.fileAddress;
      var suffix = url.substring(url.lastIndexOf("."), url.length);
      const a = document.createElement('a')
      a.setAttribute('download', name + suffix)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', url)
      a.click()
    },
    // 文件提交处理
    submitUpload() {
      this.$refs.upload.submit();
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.isUploading = false;
      this.form.fileAddress = response.url;
      this.msgSuccess(response.msg);
    },
    handleSelectChangeprocessesCode(selectedOption) {
      this.processesCodeQueryParams.processesCode = selectedOption;
      listProcesses(this.queryParams).then(response => {
@@ -383,12 +446,14 @@
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.upload.fileList = [];
      this.reset();
      this.open = true;
      this.titleName = "添加工艺文档";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.upload.fileList = [{ name: this.form.fileName, url: this.form.fileAddress }];
      this.reset();
      const id = row.id || this.ids
      getProcessFile(id).then(response => {