研发图纸文件管理系统-前端项目
he wei
2025-03-06 1164846f7c10c66264a3a88d16a31ac2fcc3a51d
U 软件添加上传源码包功能 由李文涛上传 下载
2个文件已修改
392 ■■■■■ 已修改文件
src/pages/resourceManage/software/apis.js 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/software/list.vue 347 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/software/apis.js
@@ -107,3 +107,48 @@
    }
  })
}
/**
 * 根据软件名称 下载源码
 * fileName
 */
export const downLoadCode = (fileName) => {
  return axios({
    method: "GET",
    url: "softcode/downLoadCode",
    responseType: "blob",
    params: {
      fileName
    }
  })
}
/**
 * 查询日期三天内的所有上传软件名称
 * createTime 上传日期
 */
export const getFileNameByCreateTime = (createTime) => {
  return axios({
    method: "GET",
    url: "softcode/getFileNameByCreateTime",
    params: {
      createTime
    }
  })
}
/**
 * 源码包上传
 * file
 * fileNames
 */
export const uploadCode = (data) => {
  return axios({
    method: "POST",
    url: "softcode/uploadCode",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
  })
}
src/pages/resourceManage/software/list.vue
@@ -3,19 +3,9 @@
    <div class="inner" ref="wraper">
      <a-spin class="" :spinning="spinning" tip="拼命加载中...">
        <a-card>
          <advance-table
            ref="table"
            class="doc-center-table"
            :data-source="dataSource"
            :columns="columns"
            title=""
            :row-key="(record, index) => index"
            @search="onSearch"
            @refresh="onRefresh"
            @reset="onReset"
            :format-conditions="true"
            :scroll="{ x: 2020, y }"
            :pagination="{
          <advance-table ref="table" class="doc-center-table" :data-source="dataSource" :columns="columns" title=""
            :row-key="(record, index) => index" @search="onSearch" @refresh="onRefresh" @reset="onReset"
            :format-conditions="true" :scroll="{ x: 2020, y }" :pagination="{
              current: pageCurr,
              pageSize: pageSize,
              total: total,
@@ -27,76 +17,45 @@
                `第 ${range[0]}-${range[1]} 条,总计 ${total} 条`,
              onChange: onPageChange,
              onShowSizeChange: onSizeChange,
            }"
            :rowClassName="rowClassFn"
          >
                              }" :rowClassName="rowClassFn">
            <template slot="dataIndex" slot-scope="{ index }">
              {{ index + 1 }}
            </template>
            <template slot="title">
              <a-space>
                <span class="title">软件中心</span>
                <a-button
                  v-if="canUploadSoftware"
                  type="primary"
                  @click="showUpload"
                  >上传软件</a-button
                >
                <a-button v-if="canUploadSoftware" type="primary" @click="showUpload">上传软件</a-button>
              </a-space>
            </template>
            <template slot="tags" slot-scope="tags">
              <a-tag :color="tags.record.codeFlag ? 'green' : 'red'">{{ tags.text }}</a-tag>
            </template>
            <template slot="action" slot-scope="{ record }">
              <a-popover title="" trigger="hover">
                <div class="" slot="content" style="width: 450px">
                  <a-table
                    size="small"
                    :scroll="{ y: 300 }"
                    bordered
                    :columns="prodsColumns"
                    :data-source="record.links"
                    :pagination="false"
                    :expandRowByClick="true"
                    :row-key="(record1, index) => index"
                  >
                  <a-table size="small" :scroll="{ y: 300 }" bordered :columns="prodsColumns" :data-source="record.links"
                    :pagination="false" :expandRowByClick="true" :row-key="(record1, index) => index">
                  </a-table>
                </div>
                <a>适用机型</a>
              </a-popover>
              <template v-if="canDownloadSoftware">
                <a-divider type="vertical"></a-divider>
                <a
                  :disabled="!!record.soft.lockFlag && !isTester"
                  @click="download(record)"
                  >下载</a
                >
                <a :disabled="!!record.soft.lockFlag && !isTester" @click="download(record)">下载</a>
                <a-divider type="vertical"></a-divider>
              </template>
              <a-popover title="" trigger="hover">
                <a-space class="btn-grp" direction="vertical" slot="content">
                  <a-button
                    v-if="canUploadSoftware"
                    :disabled="!!record.soft.lockFlag"
                    type="primary"
                    @click="updateDesc(record)"
                    >更新说明</a-button
                  >
                  <a-button
                    v-if="record.soft.lockFlag !== -1 ? canLock : isTester"
                    type="primary"
                    @click="lock(record)"
                    >{{ record.soft.lockFlag ? "解锁" : "锁定" }}</a-button
                  >
                  <a-button
                    v-if="canUploadSoftware"
                    type="primary"
                    @click="handleEmailShow(record)"
                    >邮件通知</a-button
                  >
                  <a-button
                    type="primary"
                    :disabled="!isTester"
                    @click="handleConfirmDelete(record)"
                    >删除</a-button
                  >
                  <a-button v-if="canUploadSoftware" :disabled="!!record.soft.lockFlag" type="primary"
                    @click="updateDesc(record)">更新说明</a-button>
                  <a-button v-if="record.soft.lockFlag !== -1 ? canLock : isTester" type="primary"
                    @click="lock(record)">{{ record.soft.lockFlag ? "解锁" : "锁定" }}</a-button>
                  <a-button v-if="canUploadSoftware" type="primary" @click="handleEmailShow(record)">邮件通知</a-button>
                  <a-button type="primary" :disabled="!isTester" @click="handleConfirmDelete(record)">删除</a-button>
                  <template v-if="isCoder">
                    <a-button type="primary" v-if="record.codeFlag" @click="downloadSource(record)">下载源码</a-button>
                    <a-button type="primary" @click="uploadSourceClick(record)">上传源码</a-button>
                  </template>
                </a-space>
                <a>更多</a>
              </a-popover>
@@ -106,39 +65,22 @@
      </a-spin>
    </div>
    <!-- 上传软件 -->
    <a-modal
      :visible="uploadShow"
      :footer="null"
      :width="760"
      :title="onlyXls ? '更新发布说明' : '上传软件'"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="uploadCancel"
    >
    <a-modal :visible="uploadShow" :footer="null" :width="760" :title="onlyXls ? '更新发布说明' : '上传软件'" :destroyOnClose="true"
      :maskClosable="false" @cancel="uploadCancel">
      <div class="">
        <template v-if="!onlyXls">
          <a-row type="flex" class="row">
            <a-col flex="6em" class="label">更新时间</a-col>
            <a-col :flex="1">
              <a-date-picker
                format="YYYY-MM-DD HH:mm:ss"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                :allowClear="false"
                :disabled-date="disabledDate"
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                v-model="versionTime"
              />
              <a-date-picker format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" :allowClear="false"
                :disabled-date="disabledDate" :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                v-model="versionTime" />
            </a-col>
          </a-row>
          <a-row type="flex" class="row">
            <a-col flex="6em" class="label">软件包</a-col>
            <a-col :flex="1">
              <a-upload
                class="upload"
                :before-upload="beforeUpload"
                @change="uploadChange"
                accept=".zip,.rar"
              >
              <a-upload class="upload" :before-upload="beforeUpload" @change="uploadChange" accept=".zip,.rar">
                <a-button type="primary">选择软件</a-button>
              </a-upload>
            </a-col>
@@ -147,12 +89,7 @@
        <a-row type="flex" class="row">
          <a-col flex="6em" class="label">软件说明</a-col>
          <a-col :flex="1">
            <a-upload
              class="upload"
              :before-upload="beforeUpload"
              @change="uploadChange1"
              accept=".xls,.xlsx"
            >
            <a-upload class="upload" :before-upload="beforeUpload" @change="uploadChange1" accept=".xls,.xlsx">
              <a-button type="primary">说明文件</a-button>
            </a-upload>
          </a-col>
@@ -170,49 +107,53 @@
        </div>
      </div>
    </a-modal>
    <pop
      :visible.sync="popVisible"
      :x="popPosition.x"
      :y="popPosition.y"
      :info="popInfo"
      :position="popPosition.dir"
    ></pop>
    <pop :visible.sync="popVisible" :x="popPosition.x" :y="popPosition.y" :info="popInfo" :position="popPosition.dir">
    </pop>
    <!-- 操作原因 -->
    <a-modal
      :visible="reasonVisible"
      :width="460"
      title="操作原因"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="reasonCancel"
      @ok="reasonOk"
    >
    <a-modal :visible="reasonVisible" :width="460" title="操作原因" :destroyOnClose="true" :maskClosable="false"
      @cancel="reasonCancel" @ok="reasonOk">
      <a-form-model-item ref="name" label="操作原因">
        <a-input
          type="textarea"
          v-model="reason"
          placeHolder="请输入操作原因"
        />
        <a-input type="textarea" v-model="reason" placeHolder="请输入操作原因" />
      </a-form-model-item>
    </a-modal>
    <!-- 上传软件 -->
    <a-modal
      :visible="emailShow"
      :footer="null"
      :width="760"
      title="邮件发送"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="emailCancel"
    >
      <email-card
        :visible.sync="emailShow"
        :users="userList"
        :title="emailInfo.title"
        :content="emailInfo.content"
        v-if="emailShow"
      ></email-card>
    <a-modal :visible="emailShow" :footer="null" :width="760" title="邮件发送" :destroyOnClose="true" :maskClosable="false"
      @cancel="emailCancel">
      <email-card :visible.sync="emailShow" :users="userList" :title="emailInfo.title" :content="emailInfo.content"
        v-if="emailShow"></email-card>
    </a-modal>
    <!-- 上传源码包 -->
    <a-modal :visible="uploadSourceShow" :footer="null" :width="760" title="上传软件源码包" :destroyOnClose="true"
      :maskClosable="false" @cancel="uploadSourceCancel">
      <div class="">
        <template>
          <a-row type="flex" class="row">
            <a-col flex="6em" class="label">对应软件</a-col>
            <a-col :flex="1">
              <a-select mode="multiple" placeholder="请选择对应的软件" show-search v-model="names" style="width: 36em;">
                <a-select-option v-for="(item, idx) in otherSoftList" :key="'soft_' + idx" :value="item.fileName">
                  {{ item.fileName }} <span class="version">({{ item.version }})</span>
                </a-select-option>
              </a-select>
            </a-col>
          </a-row>
          <a-row type="flex" class="row">
            <a-col flex="6em" class="label">软件源码包</a-col>
            <a-col :flex="1">
              <a-upload class="upload" :before-upload="beforeUpload" @change="sourceUploadChange" accept=".zip,.rar">
                <a-button type="primary">选择软件</a-button>
              </a-upload>
            </a-col>
          </a-row>
        </template>
        <div class="modal-footer">
          <a-button type="danger" @click="uploadSourceCancel"> 取消 </a-button>
          <a-button type="primary" @click="uploadSource"> 提交 </a-button>
        </div>
      </div>
    </a-modal>
  </div>
</template>
@@ -237,6 +178,9 @@
  applyModel,
  updateSoftwareLock,
  deleteSoftwareApi,
        downLoadCode,
        getFileNameByCreateTime,
        uploadCode,
} from "./apis";
import { mapGetters } from "vuex";
import EmailCard from "../../components/emailCard";
@@ -260,6 +204,9 @@
      reason: "",
      currentObj: null,
      popVisible: false,
                uploadSourceShow: false,
                names: [],
                otherSoftList: [],
      popPosition: {
        x: 0,
        y: 0,
@@ -270,6 +217,7 @@
      resData: [],
      file: null,
      file1: null,
                sourceFile: null,
      uploadShow: false,
      spinning: false,
      loading: false,
@@ -333,6 +281,22 @@
          title: "上传日期",
          dataIndex: "soft.createTime",
          align: "center",
                        noSearch: true,
                        customCell: this.customCell,
                    },
                    {
                        title: "是否已上传源码",
                        dataIndex: "codeFlagStr",
                        align: "center",
                        noSearch: true,
                        customCell: this.customCell,
            scopedSlots: { customRender: 'tags' },
                    },
          {
                        title: "源码包名称",
                        dataIndex: "codeName",
                        align: "center",
                        width: 180,
          noSearch: true,
          customCell: this.customCell,
        },
@@ -511,6 +475,10 @@
            let soft = v.softwares[0];
            return {
              id: soft.id,
                                fileName: v.fileName,
                                codeFlag: v.codeFlag,
                codeName: v.codeName || '--',
                                codeFlagStr: v.codeFlag ? '已上传源码' : '未上传源码',
              soft,
              links: v.softwares,
            };
@@ -892,6 +860,104 @@
        },
      });
    },
            // 查询其他版本 与当前软件上传日期前三天内的列表
            getOtherSoft(date) {
                return getFileNameByCreateTime(date).then((res) => {
                    let { code, data, data2 } = res.data;
                    let list = [];
                    if (code && data) {
                        console.log(data);
                        list = data2;
                    }
                    this.otherSoftList = list;
                    return list;
                })
                    .catch((err) => {
                        console.log(err);
                        return [];
                    });
            },
            sourceUploadChange(data) {
                const { file, fileList } = data;
                if (fileList.length > 1) {
                    fileList.shift();
                }
                if (fileList.length) {
                    this.sourceFile = fileList[0].originFileObj;
                } else {
                    this.sourceFile = null;
                }
            },
            // 上传源码包
            uploadSource(record) {
                if (!this.sourceFile) {
                    this.$message.error("请选择要上传的源码包");
                    return false;
                }
                if (!this.names.length) {
                    this.$message.error("请选择源码包对应的软件");
                    return false;
                }
                let loading = this.$layer.loading();
                const formData = new FormData();
                formData.append("file", this.sourceFile);
                formData.append("fileNames", this.names.join(','));
                uploadCode(formData)
                    .then((res) => {
                        let { code, data, msg } = res.data;
                        if (code) {
                            this.uploadSourceShow = false;
                            this.$message.success('上传成功');
                            this.searchData();
                        } else {
                            this.$message.error('上传失败');
                        }
                        this.$layer.close(loading);
                    })
                    .catch((error) => {
                        this.$layer.close(loading);
                        console.log(error);
                    });
            },
            // 下载源码包
            downloadSource(record) {
                let loading = this.$layer.loading();
                downLoadCode(record.fileName).then((res) => {
                    let { headers, data, status } = res;
                    if (200 == status && data) {
                        let url = window.URL.createObjectURL(data);
                        const matchRes = /filename=(.*)/.exec(headers["content-disposition"]);
                        const fileName = matchRes
                            ? decodeURI(matchRes[1].trim())
                            : "未知文件名.zip";
                        let link = document.createElement("a");
                        link.style.display = "none";
                        link.href = url;
                        link.download = fileName;
                        document.body.appendChild(link);
                        link.click();
                        this.$layer.close(loading);
                        document.body.removeChild(link);
                        window.URL.revokeObjectURL(url);
                    } else {
                        this.$layer.close(loading);
                        this.$message.error("操作失败");
                    }
                });
            },
            async uploadSourceClick(obj) {
                console.log('obj', obj, '=============');
                this.currentObj = obj;
                let date = obj.soft.createTime.split(' ')[0];
                await this.getOtherSoft(date);
                this.names = [obj.fileName];
                this.uploadSourceShow = true;
            },
            uploadSourceCancel() {
                this.uploadSourceShow = false;
            },
  },
  watch: {
    update(n) {
@@ -942,6 +1008,9 @@
    isTester() {
      return this.tester.some((v) => v == this.user.name);
    },
            isCoder() {
                return '李文涛' == this.user.name;
            }
  },
  mounted() {
    this.getRoleUser();
@@ -959,6 +1028,7 @@
.main {
  height: 100%;
  position: relative;
  .inner {
    position: absolute;
    left: 0;
@@ -967,33 +1037,42 @@
    bottom: 0;
  }
}
/deep/table {
  table-layout: fixed;
}
.modal-footer {
  text-align: right;
  button + button {
    margin-left: 8px;
  }
}
.label {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 0.4em;
  height: 32px;
  &::after {
    content: ":";
  }
}
.row ~ .row {
  margin-top: 10px;
}
.upload {
  display: flex;
  /deep/.ant-upload-list {
    flex: 1;
    position: relative;
    & > div {
      position: absolute;
      left: 0;
@@ -1001,24 +1080,36 @@
    }
  }
}
.sub-title {
  font-size: 14px;
  font-weight: 700;
  margin-top: 10px;
}
.res-content {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.btn-grp button {
  width: 6.4em;
}
/deep/.locked > td {
  background: #fec54b;
}
/deep/.locked.locked.locked.ant-table-row-hover > td,
/deep/.locked.locked.locked:hover > td {
  background: #fcd583;
}
.version {
  color: #090;
  display: inline-block;
  font-weight: bold;
  padding: 0 0.4em;
  margin-left: 0.4em;
}
</style>