Pārlūkot izejas kodu

产品项目管理-导入

damon227 1 mēnesi atpakaļ
vecāks
revīzija
023f6b8019

+ 111 - 0
src/views/modules/tech/project-product-assign.vue

@@ -0,0 +1,111 @@
+<template>
+  <div>
+    <div class="my-title">分派</div>
+    <el-form
+      :model="dataForm"
+      :rules="dataRule"
+      ref="dataForm"
+      label-width="auto"
+    >
+      <el-row class="my-row">
+        <el-col :span="24">
+          <el-form-item label="责任人" prop="responsibilityPerson">
+            <user-component
+              v-model="dataForm.responsibilityPerson"
+              :user-id="dataForm.responsibilityPerson"
+              @userSelected="selectChange"
+            />
+          </el-form-item>
+        </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 UserComponent from '../common/user-component'
+export default {
+  name: 'project-product-assign',
+  components: { UserComponent },
+  computed: {},
+  data () {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {},
+      dataRule: {
+        responsibilityPerson: [
+          {
+            required: true,
+            message: '请选择责任人',
+            trigger: 'blur'
+          }
+        ]
+      }
+    }
+  },
+  created () {},
+  beforeDestroy () {},
+  methods: {
+    onChose () {
+      this.$emit('onChose')
+    },
+    async init (item, display) {
+      this.dataForm = item
+
+      this.visible = true
+    },
+    validateField (type) {
+      this.$refs.dataForm.validateField(type)
+    },
+    // 表单提交
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          this.$http({
+            url: this.$http.adornUrl(`/biz-service/projProduct/assign`),
+            method: 'post',
+            data: this.$http.adornData({
+              productTechnologyId: this.dataForm.productTechnologyId,
+              responsibilityPerson: this.dataForm.responsibilityPerson
+            })
+          }).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)
+            }
+          })
+        }
+      })
+    },
+    selectChange (val) {
+      this.dataForm.responsibilityPerson = val
+    }
+  }
+}
+</script>
+
+<style scoped>
+.my-row {
+  margin-bottom: 20px;
+}
+</style>

+ 148 - 0
src/views/modules/tech/project-product-selection.vue

@@ -0,0 +1,148 @@
+<template>
+  <div>
+    <div class="my-title">选择清单</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="productName">
+            <el-input v-model="dataForm.productName" placeholder="" clearable></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item>
+            <el-button @click="queryData()">查询</el-button>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <el-table
+      ref="multipleTable"
+      :data="dataList"
+      tooltip-effect="dark"
+      style="width: 100%"
+      @selection-change="handleSelectionChange"
+       @row-click="clickRow"
+    >
+      <el-table-column type="selection" width="55"> </el-table-column>
+      <el-table-column prop="projectName" label="项目名称"> </el-table-column>
+      <el-table-column prop="productName" label="物料名称"></el-table-column>
+    </el-table>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">取消</el-button>
+      <el-button
+        type="primary"
+        @click="dataFormSubmit()"
+        v-reClick
+        >确定</el-button
+      >
+    </span>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'project-product-selection',
+  components: {},
+  computed: {},
+  data () {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {},
+      dataList: [],
+      totalPage: 0,
+      multipleSelection: [],
+      dataRule: {}
+    }
+  },
+  created () {},
+  beforeDestroy () {},
+  methods: {
+    onChose () {
+      this.$emit('onChose')
+    },
+    async init (item) {
+      this.dataForm = item
+
+      this.queryData()
+    },
+    // 查询
+    queryData () {
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 获取数据列表
+    getDataList () {
+      this.$http({
+        url: this.$http.adornUrl(`/biz-service/proProductBom/list`),
+        method: 'get',
+        params: this.$http.adornParams({
+          current: this.pageIndex,
+          size: this.pageSize,
+          productName: this.dataForm.productName
+        })
+      }).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.dataList = data.data.records
+          this.totalPage = Number(data.data.total)
+        } else {
+          this.dataList = []
+          this.totalPage = 0
+        }
+      })
+    },
+    handleSelectionChange (val) {
+      if (val.length > 1) {
+        this.$refs.multipleTable.clearSelection() // 清除所有选中
+        this.$refs.multipleTable.toggleRowSelection(val.pop()) // 重新选中最后一项
+      } else {
+        this.selectedRow = val[0] || null
+      }
+    },
+    // 点击行时触发选中
+    clickRow (row) {
+      this.$refs.multipleTable.clearSelection()
+      this.$refs.multipleTable.toggleRowSelection(row)
+    },
+    // 表单提交
+    dataFormSubmit () {
+      if (this.multipleSelection == null || this.multipleSelection.length === 0) {
+        this.$message.error('请选择清单')
+        return
+      }
+      this.$http({
+        url: this.$http.adornUrl(`/biz-service/projProduct/selection`),
+        method: 'post',
+        data: this.$http.adornData({
+          productTechnologyId: this.multipleSelection[0].productTechnologyId
+        })
+      }).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)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.my-row {
+  margin-bottom: 20px;
+}
+</style>

+ 89 - 10
src/views/modules/tech/project-product.vue

@@ -1,7 +1,7 @@
 <!-- 工种管理 -->
 <template>
   <div class="work-type">
-    <template v-if="!addOrUpdateVisible && !detailVisible">
+    <template v-if="!addOrUpdateVisible && !detailVisible && !assignVisible && !selectionVisible">
       <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
         <el-form-item label="项目名称">
           <el-input v-model="dataForm.projectName" placeholder="" clearable/>
@@ -68,9 +68,9 @@
           label="操作">
           <template slot-scope="scope">
             <el-button type="text" size="small" @click="detailHandle(scope.row)">查看</el-button>
-            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row, false)">分派</el-button>
-            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row, false)">选择清单</el-button>
-            <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row, false)">导入</el-button>
+            <el-button type="text" size="small" @click="assignHandle(scope.row)">分派</el-button>
+            <el-button type="text" size="small" @click="selectionHandle(scope.row, false)">选择清单</el-button>
+            <el-button type="text" size="small" @click="importHandle(scope.row)">导入</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -86,23 +86,44 @@
     </template>
     <!-- 弹窗, 新增 / 修改 -->
     <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
+    <assign v-if="assignVisible" ref="assign" @onChose="onChose"/>
+    <selection v-if="selectionVisible" ref="selection" @onChose="onChose"/>
 
+    <el-dialog title="导入" :visible.sync="importVisible">
+      <el-upload
+        class="upload-demo"
+        ref="upload"
+        :on-remove="handleRemove"
+        action="#"
+        :limit="1"
+        :file-list="fileList"
+        :auto-upload="false"
+        :http-request="handleUpload"
+        v-loading="importLoading"
+        >
+        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+        <el-button size="small" type="success" @click="submitUpload" >开始上传</el-button>
+      </el-upload>
+    </el-dialog>
   </div>
 </template>
 
 <script>
   import Detail from './project-product-detail'
-  import { getList } from '@/api/sealmanage'
-  import AttachDetailDialog from '../common/attach-detail-dialog'
+  import Assign from './project-product-assign'
+  import Selection from './project-product-selection'
   export default {
     name: 'file-manage',
     components: {
-      Detail, AttachDetailDialog
+      Detail, Assign, Selection
     },
     data () {
       return {
         addOrUpdateVisible: false,
         detailVisible: false,
+        assignVisible: false,
+        selectionVisible: false,
+        importVisible: false,
         dataForm: {},
         dataList: [],
         pageIndex: 1,
@@ -110,7 +131,10 @@
         totalPage: 0,
         dataListLoading: false,
         dataListSelections: [],
-        optionsLevel: []
+        optionsLevel: [],
+        importLoading: false,
+        importData: {},
+        fileList: []
       }
     },
     created () {
@@ -120,6 +144,8 @@
       onChose () {
         this.addOrUpdateVisible = false
         this.detailVisible = false
+        this.assignVisible = false
+        this.selectionVisible = false
       },
       // 查询
       queryData () {
@@ -181,8 +207,61 @@
           this.$refs.detail.init(item)
         })
       },
-      attachDetails (attachList) {
-        this.$refs.attachDetail.init(attachList)
+      assignHandle (item) {
+        this.assignVisible = true
+        this.$nextTick(() => {
+          this.$refs.assign.init(item)
+        })
+      },
+      selectionHandle (item) {
+        this.selectionVisible = true
+        this.$nextTick(() => {
+          this.$refs.selection.init(item)
+        })
+      },
+      importHandle (item) {
+        this.importVisible = true
+        this.importData = item
+      },
+      // 上传
+      submitUpload () {
+        this.$refs.upload.submit()
+      },
+      // 移除
+      handleRemove (file, fileList) {
+        this.$emit('input', fileList)
+      },
+      handleUpload (file) {
+        if (file == null) {
+          this.$message.error('请上传文件')
+          return
+        }
+
+        this.importLoading = true
+
+        const formData = new FormData()
+        formData.append('importFile', file.file)
+        formData.append('productTechnologyId', this.importData.productTechnologyId)
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/projProduct/importExcel`),
+          method: 'POST',
+          data: formData,
+          timeout: 0
+        }).then(({data}) => {
+          this.importLoading = false
+          if (data && data.code === '200') {
+            this.$message({
+              message: '导入成功',
+              type: 'success',
+              duration: 1500,
+              onClose: () => {
+                this.importVisible = false
+              }
+            })
+          } else {
+            this.$message.error(data.msg)
+          }
+        })
       }
     }
   }