瀏覽代碼

技术文件管理

damon227 1 月之前
父節點
當前提交
182925d200

+ 28 - 0
src/api/filemanage.js

@@ -0,0 +1,28 @@
+import request from '@/utils/httpRequest'
+
+// 技术文件管理列表
+export function getList (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/pro-documents/list`),
+    method: 'get',
+    params: data
+  })
+}
+
+// 上传技术文件
+export function save (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/pro-documents/save`),
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改技术文件
+export function update (data) {
+  return request({
+    url: request.adornUrl(`/biz-service/pro-documents/update`),
+    method: 'post',
+    data: data
+  })
+}

+ 1 - 1
src/views/modules/sale/add-material.vue

@@ -181,7 +181,7 @@ export default {
   },
   methods: {
     init (id, display, transferData) {
-      this.remoteMethod('')
+      this.remoteMethod()
 
       this.dataForm = {
         cnt: 1

+ 255 - 0
src/views/modules/tech/file-manage-add-or-update.vue

@@ -0,0 +1,255 @@
+<template>
+  <div>
+    <div class="my-title">{{ !id ? "新增" : display ? "详情" : "修改" }}</div>
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      label-width="auto"
+    >
+      <el-row class="my-row">
+        <el-col :span="8">
+          <el-form-item label="任务单" prop="orderId">
+            <el-select
+              v-model="dataForm.orderId"
+              :disabled="display"
+              filterable
+              remote
+              reserve-keyword
+              placeholder="请输入关键词"
+              :remote-method="debouncedSearch"
+              :loading="loading"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in orderOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="16">
+          <el-form-item label="备注" prop="notes">
+            <el-input v-model="dataForm.notes" placeholder="" type="textarea" :rows="2"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="8">
+          <upload-component
+            :title="'技术协议'"
+            :accept="'*'"
+            :file-obj-list="fileList"
+            @uploadSuccess="uploadSuccess"
+          />
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="8">
+          <upload-component
+            :title="'技术文件'"
+            :accept="'*'"
+            :file-obj-list="fileList1"
+            @uploadSuccess="uploadSuccess1"
+          />
+        </el-col>
+      </el-row>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">取消</el-button>
+      <el-button
+        v-if="!display"
+        type="primary"
+        @click="dataFormSubmit()"
+        v-reClick
+        >确定</el-button
+      >
+    </span>
+  </div>
+</template>
+
+<script>
+import { save, update } from '@/api/filemanage'
+import { getOrderByCode } from '@/api/sale'
+import _ from 'lodash'
+import UploadComponent from '../common/upload-component'
+export default {
+  name: 'work-type-add-or-update',
+  components: { UploadComponent },
+  computed: {},
+  data () {
+    return {
+      visible: false,
+      display: false,
+      id: 0,
+      dataForm: {},
+      loading: false,
+      orderOptions: [],
+      fileList: [],
+      fileList1: [],
+      dataRule: {
+        orderId: [
+          { required: true, message: '任务单不能为空', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created () {
+    // 创建防抖函数(500ms延迟)
+    this.debouncedSearch = _.debounce(this.remoteMethod, 500)
+  },
+  beforeDestroy () {
+    // 清除防抖定时器,避免内存泄漏
+    this.debouncedSearch.cancel()
+  },
+  methods: {
+    onChose () {
+      this.$emit('onChose')
+    },
+    async init (item, display) {
+      this.remoteMethod()
+
+      if (item != null) {
+        this.dataForm = item
+        this.id = 1 // 固定为1,无意义,仅为判断是新增还是修改
+
+        // 附件
+        if (this.dataForm.attachList) {
+          this.dataForm.attachList.forEach((item) => {
+            this.fileList.push({
+              name: item.fileName,
+              url: item.url,
+              id: item.url
+            })
+          })
+        }
+        if (this.dataForm.attachList1) {
+          this.dataForm.attachList1.forEach((item) => {
+            this.fileList1.push({
+              name: item.fileName,
+              url: item.url,
+              id: item.url
+            })
+          })
+        }
+      } else {
+        this.dataForm = {}
+        this.id = null
+      }
+
+      this.visible = true
+      this.display = display
+    },
+    validateField (type) {
+      this.$refs.dataForm.validateField(type)
+    },
+    // 表单提交
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          if (this.fileList.length === 0) {
+            this.$message.error('请上传技术协议')
+            return
+          }
+          if (this.fileList1.length === 0) {
+            this.$message.error('请上传技术文件')
+            return
+          }
+
+          let data = {
+            technicalDocumentsId: this.dataForm.technicalDocumentsId,
+            orderId: this.dataForm.orderId,
+            notes: this.dataForm.notes,
+            attachList: [],
+            attachList1: []
+          }
+
+          for (let i = 0; i < this.fileList.length; i++) {
+            data.attachList.push({
+              fileName: this.fileList[i].name,
+              url: this.fileList[i].url
+            })
+          }
+
+          for (let i = 0; i < this.fileList1.length; i++) {
+            data.attachList1.push({
+              fileName: this.fileList1[i].name,
+              url: this.fileList1[i].url
+            })
+          }
+
+          if (this.id) {
+            update(data)
+            .then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.onChose()
+                    this.$emit('refreshDataList')
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+            .catch(() => {})
+          } else {
+            save(data)
+            .then(({ data }) => {
+              if (data && data.code === '200') {
+                this.$message({
+                  message: '操作成功',
+                  type: 'success',
+                  duration: 1500,
+                  onClose: () => {
+                    this.onChose()
+                    this.$emit('refreshDataList')
+                  }
+                })
+              } else {
+                this.$message.error(data.msg)
+              }
+            })
+            .catch(() => {})
+          }
+        }
+      })
+    },
+    remoteMethod (query) {
+      this.loading = true
+      this.getOrderByCode(query)
+    },
+    getOrderByCode (orderCode) {
+      getOrderByCode(orderCode).then(({ data }) => {
+        this.loading = false
+
+        if (data && data.code === '200' && data.data) {
+          this.orderOptions = data.data.map((item) => {
+            return { label: item.orderCode, value: item.orderId }
+          })
+        }
+      })
+    },
+    uploadSuccess (fileList) {
+      this.fileList = fileList
+    },
+    uploadSuccess1 (fileList) {
+      this.fileList1 = fileList
+    }
+  }
+}
+</script>
+
+<style scoped>
+.my-row {
+  margin-bottom: 20px;
+}
+</style>

+ 81 - 0
src/views/modules/tech/file-manage-detail.vue

@@ -0,0 +1,81 @@
+<template>
+  <div>
+    <div class="my-title">查看</div>
+    <div style="margin-left: 20px; margin-right: 20px">
+      <e-desc title="基本信息" column="3">
+        <e-desc-item label="项目名称">{{ dataForm.code }}</e-desc-item>
+        <e-desc-item label="任务号">{{ dataForm.name }}</e-desc-item>
+       
+        <e-desc-item label="备注" span="3">{{ dataForm.notes }}</e-desc-item>
+
+        <e-desc-item v-if="dataForm.attachList" label="技术协议" span="3">
+          <div v-for="(item, index) in dataForm.attachList" style="display: inline">
+            <span v-if="index > 0">,</span>
+            <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
+          </div>
+        </e-desc-item>
+
+         <e-desc-item v-if="dataForm.attachList1" label="技术文件" span="3">
+          <div v-for="(item, index) in dataForm.attachList1" style="display: inline">
+            <span v-if="index > 0">,</span>
+            <a :key="item.fileName + index" type="primary" href="#" @click="previewFile(item.fileName, item.url)">{{ item.fileName }}</a>
+          </div>
+        </e-desc-item>
+      </e-desc>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">返回</el-button>
+    </span>
+
+    <!-- 文件预览 -->
+    <preview-component v-if="previewVisible" ref="preview"/>
+  </div>
+</template>
+
+<script>
+import EDesc from '../common/e-desc'
+import EDescItem from '../common/e-desc-item'
+import PreviewComponent from '../common/preview-component'
+export default {
+  name: 'work-type-detail',
+  components: {
+    EDesc,
+    EDescItem,
+    PreviewComponent
+  },
+  data () {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {},
+      previewVisible: false
+    }
+  },
+  methods: {
+    onChose () {
+      this.$emit('onChose')
+    },
+    async init (item) {
+      this.visible = true
+      this.dataForm = item
+    },
+     // 预览
+    previewFile (fileName, url) {
+      this.previewVisible = true
+      this.$nextTick(() => {
+        this.$refs.preview.init(fileName, url)
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.my-line {
+  border-bottom: 1px solid #c0c4cc;
+  margin-bottom: 10px;
+}
+.title {
+  padding: 10px 0;
+}
+</style>

+ 219 - 0
src/views/modules/tech/file-manage.vue

@@ -0,0 +1,219 @@
+<!-- 工种管理 -->
+<template>
+  <div class="work-type">
+    <template v-if="!addOrUpdateVisible && !detailVisible">
+      <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
+        <el-form-item label="项目/任务号">
+          <el-input v-model="dataForm.orderCode" placeholder="" clearable/>
+        </el-form-item>
+        <el-form-item>
+          <el-button @click="queryData()">查询</el-button>
+          <el-button type="primary" @click="addOrUpdateHandle(null, false)">上传</el-button>
+        </el-form-item>
+      </el-form>
+      <el-table
+        :data="dataList"
+        border
+        v-loading="dataListLoading"
+        style="width: 100%;">
+        <el-table-column
+          label="序号"
+          type="index"
+          width="50"
+          align="center">
+        </el-table-column>
+         <el-table-column
+          prop="projectName"
+          header-align="center"
+          align="center"
+          min-width="140"
+          :show-tooltip-when-overflow="true"
+          label="项目名称">
+        </el-table-column>
+        <el-table-column
+          prop="orderCode"
+          header-align="center"
+          align="center"
+          min-width="160"
+          :show-tooltip-when-overflow="true"
+          label="任务号">
+        </el-table-column>
+        <el-table-column
+          prop="attachList"
+          header-align="center"
+          align="center"
+          :show-tooltip-when-overflow="true"
+          label="技术协议"
+        >
+        <template slot-scope="scope">
+            <el-button
+              :disabled="
+                !scope.row.attachList || scope.row.attachList.length === 0
+              "
+              type="text"
+              size="small"
+              @click="attachDetails(scope.row.attachList)"
+              >查看</el-button
+            >
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="attachList1"
+          header-align="center"
+          align="center"
+          :show-tooltip-when-overflow="true"
+          label="技术文件"
+        >
+        <template slot-scope="scope">
+            <el-button
+              :disabled="
+                !scope.row.attachList1 || scope.row.attachList1.length === 0
+              "
+              type="text"
+              size="small"
+              @click="attachDetails(scope.row.attachList1)"
+              >查看</el-button
+            >
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="notes"
+          header-align="center"
+          align="center"
+         :show-tooltip-when-overflow="true"
+          label="备注">
+        </el-table-column>
+        <el-table-column
+          prop="createTime"
+          header-align="center"
+          align="center"
+          min-width="120"
+          :show-tooltip-when-overflow="true"
+          label="创建时间">
+        </el-table-column>
+        <el-table-column
+          fixed="right"
+          header-align="center"
+          align="center"
+          width="150"
+          label="操作">
+          <template slot-scope="scope">
+            <el-button v-if="isAuth('pro:worktype:info')" type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
+            <el-button v-if="isAuth('pro:worktype:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row, false)">编辑</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        @size-change="sizeChangeHandle"
+        @current-change="currentChangeHandle"
+        :current-page="pageIndex"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="pageSize"
+        :total="totalPage"
+        layout="total, sizes, prev, pager, next, jumper">
+      </el-pagination>
+    </template>
+    <!-- 弹窗, 新增 / 修改 -->
+    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
+    <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
+
+    <attach-detail-dialog ref="attachDetail" @onChose="onChose" />
+  </div>
+</template>
+
+<script>
+  import AddOrUpdate from './file-manage-add-or-update'
+  import Detail from './file-manage-detail'
+  import { getList } from '@/api/filemanage'
+  import AttachDetailDialog from '../common/attach-detail-dialog'
+  export default {
+    name: 'file-manage',
+    components: {
+      AddOrUpdate, Detail, AttachDetailDialog
+    },
+    data () {
+      return {
+        addOrUpdateVisible: false,
+        detailVisible: false,
+        dataForm: {},
+        dataList: [],
+        pageIndex: 1,
+        pageSize: 10,
+        totalPage: 0,
+        dataListLoading: false,
+        dataListSelections: [],
+        optionsLevel: []
+      }
+    },
+    created () {
+      this.getDataList()
+    },
+    methods: {
+      onChose () {
+        this.addOrUpdateVisible = false
+        this.detailVisible = false
+      },
+      // 查询
+      queryData () {
+        this.pageIndex = 1
+        this.getDataList()
+      },
+      // 获取数据列表
+      getDataList () {
+        this.dataListLoading = true
+        this.addOrUpdateVisible = false
+        let params = {
+          'current': this.pageIndex,
+          'size': this.pageSize,
+          'orderCode': this.dataForm.orderCode ? this.dataForm.orderCode : null
+        }
+        getList(params).then(({data}) => {
+          if (data && data.code === '200') {
+            this.dataList = data.data.records
+            this.totalPage = Number(data.data.total)
+          } else {
+            this.dataList = []
+            this.totalPage = 0
+          }
+          this.dataListLoading = false
+        })
+      },
+      // 每页数
+      sizeChangeHandle (val) {
+        this.pageSize = val
+        this.pageIndex = 1
+        this.getDataList()
+      },
+      // 当前页
+      currentChangeHandle (val) {
+        this.pageIndex = val
+        this.getDataList()
+      },
+      // 多选
+      selectionChangeHandle (val) {
+        this.dataListSelections = val
+      },
+      // 新增 / 修改
+      addOrUpdateHandle (item, disable) {
+        this.addOrUpdateVisible = true
+        this.$nextTick(() => {
+          this.$refs.addOrUpdate.init(item, disable)
+        })
+      },
+      // 详情
+      detailHandle (item) {
+        this.detailVisible = true
+        this.$nextTick(() => {
+          this.$refs.detail.init(item)
+        })
+      },
+      attachDetails (attachList) {
+        this.$refs.attachDetail.init(attachList)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>