123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761 |
- <!-- BOM清单 -->
- <template>
- <div class="product-management">
- <template v-if="!addOrUpdateVisible && !changeFormVisible && !attachVisible && !detailVisible && !craftsVisible && !drawVisible && !changeVisible && !noticeChangeVisible && !importVisible">
- <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
- <el-form-item label="名称">
- <el-input v-model="dataForm.productName" placeholder="物料名称" clearable/>
- </el-form-item>
- <el-form-item label="物料类别">
- <el-select
- v-model="dataForm.productType"
- remote
- placeholder="请选择">
- <el-option
- v-for="item in optionsType"
- :key="item.code"
- :label="item.value"
- :value="item.code">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="图号">
- <el-input v-model="dataForm.mapNumber" placeholder="图号" clearable/>
- </el-form-item>
- <!-- <el-form-item label="是否组合">-->
- <!-- <el-select-->
- <!-- v-model="dataForm.isCompose"-->
- <!-- placeholder="请选择">-->
- <!-- <el-option-->
- <!-- v-for="item in optionsCompose"-->
- <!-- :key="item.value"-->
- <!-- :label="item.label"-->
- <!-- :value="item.value">-->
- <!-- </el-option>-->
- <!-- </el-select>-->
- <!-- </el-form-item>-->
- <el-form-item>
- <el-button @click="search()">查询</el-button>
- <el-button v-if="isAuth('pro:product:save')" type="primary" @click="addOrUpdateHandle(0, false)">新建</el-button>
- <el-button v-if="isAuth('pro:product:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">变更通知人设置</el-button>
- <el-button type="primary" @click="importFromExcel">导入清单</el-button>
- <el-button type="primary" @click="templateDownload">清单模板下载</el-button>
- </el-form-item>
- </el-form>
- <el-table
- :data="dataList"
- row-key="productId"
- border
- :indent='20'
- lazy
- :load="loadingData"
- v-loading="dataListLoading"
- style="width: 100%;">
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center">
- </el-table-column>
- <el-table-column
- prop="productCode"
- header-align="center"
- align="center"
- width="200"
- :show-tooltip-when-overflow="true"
- label="物料编码">
- </el-table-column>
- <el-table-column
- prop="mapNumber"
- header-align="center"
- align="center"
- width="120"
- :show-tooltip-when-overflow="true"
- label="图号">
- </el-table-column>
- <el-table-column
- prop="simplePic"
- header-align="center"
- align="center"
- min-width="120"
- label="简图">
- <template slot-scope="scope">
- <el-popover placement="right" title="" trigger="hover">
- <img :src="scope.row.simplePic" style="height: 400px;width: 500px">
- <img slot="reference" :src="scope.row.simplePic" :alt="scope.row.simplePic" style="max-height: 50px;max-width: 130px">
- </el-popover>
- </template>
- </el-table-column>
- <el-table-column
- prop="productName"
- header-align="center"
- align="center"
- width="140"
- :show-tooltip-when-overflow="true"
- label="物料名称">
- </el-table-column>
- <el-table-column
- prop="importance"
- header-align="center"
- align="center"
- width="140"
- :show-tooltip-when-overflow="true"
- label="关重件">
- </el-table-column>
- <el-table-column
- prop="productSpec"
- header-align="center"
- align="center"
- width="140"
- :show-tooltip-when-overflow="true"
- label="物料规格">
- </el-table-column>
- <el-table-column
- prop="productType"
- header-align="center"
- align="center"
- min-width="120"
- :formatter="typeFormat"
- label="类别">
- </el-table-column>
- <el-table-column
- prop="isCompose"
- header-align="center"
- align="center"
- min-width="80"
- :formatter="composeFormat"
- label="是否组合">
- </el-table-column>
- <el-table-column
- prop="materials"
- header-align="center"
- align="center"
- width="140"
- :show-tooltip-when-overflow="true"
- label="材料">
- </el-table-column>
- <el-table-column
- prop="cnt"
- header-align="center"
- align="center"
- label="单套数量">
- </el-table-column>
- <el-table-column
- prop="unit"
- header-align="center"
- align="center"
- label="单位">
- </el-table-column>
- <el-table-column
- prop="size"
- header-align="center"
- align="center"
- label="物料尺寸">
- </el-table-column>
- <el-table-column
- prop="developedSize"
- header-align="center"
- align="center"
- width="100"
- :show-tooltip-when-overflow="true"
- label="展开尺寸">
- </el-table-column>
- <el-table-column
- prop="surfaceTreatment"
- header-align="center"
- align="center"
- width="100"
- :show-tooltip-when-overflow="true"
- label="表面处理">
- </el-table-column>
- <el-table-column
- prop="heatTreatment"
- header-align="center"
- align="center"
- width="100"
- :show-tooltip-when-overflow="true"
- label="热处理">
- </el-table-column>
- <el-table-column
- prop="sourceName"
- header-align="center"
- align="center"
- width="160"
- :show-overflow-tooltip="true"
- label="来源">
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- width="140"
- :show-overflow-tooltip="true"
- label="更改说明">
- <template slot-scope="scope">
- <span>{{scope.row.noticeChangeRecord?scope.row.noticeChangeRecord.description:''}}</span>
- </template>
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- label="更改单">
- <template slot-scope="scope">
- <el-button :disabled="!scope.row.noticeChangeRecord || !scope.row.noticeChangeRecord.attachList || scope.row.noticeChangeRecord.attachList.length === 0" type="text" size="small" @click="changeDetails(scope.row)">查看</el-button>
- </template>
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- label="技术文件">
- <template slot-scope="scope">
- <el-button :disabled="!scope.row.attachList || scope.row.attachList.length === 0" type="text" size="small" @click="attachDetails(scope.row)">查看</el-button>
- </template>
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- label="物料配料清单">
- <template slot-scope="scope">
- <el-button :disabled="!scope.row.listingList || scope.row.listingList.length === 0" type="text" size="small" @click="attachDetails2(scope.row)">查看</el-button>
- </template>
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- label="对应图纸">
- <template slot-scope="scope">
- <el-button :disabled="!scope.row.proDrawings || scope.row.proDrawings.length === 0" type="text" size="small" @click="drawDetails(scope.row)">查看</el-button>
- </template>
- </el-table-column>
- <el-table-column
- header-align="center"
- align="center"
- label="对应工艺">
- <template slot-scope="scope">
- <el-button :disabled="!scope.row.techId" type="text" size="small" @click="techDetails(scope.row.techId)">查看</el-button>
- </template>
- </el-table-column>
- <el-table-column
- prop="createTime"
- header-align="center"
- align="center"
- min-width="160"
- label="创建时间">
- </el-table-column>
- <el-table-column
- prop="creatorName"
- header-align="center"
- align="center"
- min-width="100"
- label="创建人">
- </el-table-column>
- <el-table-column
- prop="notes"
- header-align="center"
- align="center"
- min-width="180"
- :show-overflow-tooltip="true"
- label="备注">
- </el-table-column>
- <el-table-column
- fixed="right"
- header-align="center"
- align="center"
- min-width="80"
- :formatter="formatState"
- :show-overflow-tooltip="true"
- label="状态">
- </el-table-column>
- <el-table-column
- fixed="right"
- header-align="center"
- align="center"
- min-width="80"
- :formatter="formatReadState"
- :show-overflow-tooltip="true"
- label="读写状态">
- </el-table-column>
- <el-table-column
- fixed="right"
- header-align="center"
- align="center"
- width="240"
- label="操作">
- <template slot-scope="scope">
- <el-button v-if="isAuth('pro:product:info')" type="text" size="small" @click="detailHandle(scope.row.productId)">查看</el-button>
- <el-button v-if="isAuth('pro:product:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.productId, false)">编辑</el-button>
- <el-button v-if="isAuth('pro:product:change')" type="text" size="small" @click="changeHandle(scope.row.productId)">变更</el-button>
- <el-button v-if="isAuth('pro:product:read') && Number(scope.row.writeState) === 2" type="text" size="small" @click="readHandle(scope.row.productId)">只读</el-button>
- <el-button v-if="isAuth('pro:product:write') && Number(scope.row.writeState) === 1" type="text" size="small" @click="writeHandle(scope.row.productId)">读写</el-button>
- <el-button v-if="isAuth('pro:product:pause') && Number(scope.row.state) === 1" type="text" size="small" @click="pauseHandle(scope.row.productId)">暂停生产</el-button>
- <el-button v-if="isAuth('pro:product:regain') && Number(scope.row.state) === 2" type="text" size="small" @click="regainHandle(scope.row.productId)">恢复生产</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"/>
- <crafts-detail v-if="craftsVisible" ref="craftsDetail" @onChose="onChose"/>
- <product-draw-detail v-if="drawVisible" ref="drawDetail" @onChose="onChose"/>
- <attach-detail v-if="changeVisible" ref="changeDetail" @onChose="onChose"/>
- <attach-detail v-if="attachVisible" ref="attachDetail" @onChose="onChose"/>
- <notice-change-setting v-if="noticeChangeVisible" ref="noticeChangeSetting" @onChose="onChose"/>
- <change-form v-if="changeFormVisible" ref="changeForm" @refreshDataList="getDataList" @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 Vue from 'vue'
- import AddOrUpdate from './product-add-or-update'
- import Detail from './product-detail'
- import { getDictList } from '@/api/dict'
- import { getProductList, getChildren } from '@/api/product'
- import CraftsDetail from './crafts-detail'
- import ProductDrawDetail from './product-draw-detail'
- import AttachDetail from '../common/attach-detail'
- import NoticeChangeSetting from './product-notice-change-setting'
- import ChangeForm from './product-change'
- import {bomStateOption, writeStateOption, optionsCompose} from '@/utils/enums'
- import UploadComponent from '@/views/modules/common/upload-component-v2'
- import { downloadUrl } from '@/api/file'
- export default {
- name: 'product-management',
- components: {
- AttachDetail,
- ProductDrawDetail,
- CraftsDetail,
- AddOrUpdate,
- Detail,
- NoticeChangeSetting,
- ChangeForm,
- UploadComponent
- },
- data () {
- return {
- addOrUpdateVisible: false,
- attachVisible: false,
- detailVisible: false,
- craftsVisible: false,
- drawVisible: false,
- changeVisible: false,
- noticeChangeVisible: false,
- changeFormVisible: false,
- importVisible: false,
- dataForm: {},
- dataList: [],
- pageIndex: 1,
- pageSize: 10,
- totalPage: 0,
- dataListLoading: false,
- dataListSelections: [],
- optionsType: [],
- bomStateOption: bomStateOption,
- writeStateOption: writeStateOption,
- optionsCompose: optionsCompose,
- importForm: {},
- importLoading: false,
- fileList: []
- }
- },
- created () {
- this.getTypeList()
- // this.getStateList()
- this.getDataList()
- },
- methods: {
- onChose () {
- this.addOrUpdateVisible = false
- this.attachVisible = false
- this.detailVisible = false
- this.craftsVisible = false
- this.drawVisible = false
- this.changeVisible = false
- this.noticeChangeVisible = false
- this.changeFormVisible = false
- },
- // 获取物料类别字典
- getTypeList () {
- getDictList({type: 'product_type'}).then(({data}) => {
- if (data) {
- this.optionsType = data
- }
- })
- },
- // 查询
- search () {
- this.pageIndex = 1
- this.getDataList()
- },
- // 获取数据列表
- getDataList () {
- this.dataListLoading = true
- this.addOrUpdateVisible = false
- let params = {
- ...this.dataForm,
- 'current': this.pageIndex,
- 'size': this.pageSize
- }
- getProductList(params).then(({data}) => {
- if (data && data.code === '200') {
- this.dataList = data.data.records
- // this.dataList = JSON.parse(JSON.stringify(data.data.records).replace(/"children":null/g, '"children":[]'))
- this.dataList.forEach(item => {
- if (item.attachList2 && item.attachList2.length > 0) {
- item.simplePic = downloadUrl + item.attachList2[0].url
- } else {
- item.simplePic = ''
- }
- })
- this.totalPage = Number(data.data.total)
- } else {
- this.dataList = []
- this.totalPage = 0
- }
- this.dataListLoading = false
- })
- },
- deleteHandle (id) {
- if (!id) return
- let ids = []
- ids.push(id)
- this.$confirm(`确定删除?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/delete`),
- method: 'DELETE',
- data: ids
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.getDataList()
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }).catch(() => {})
- },
- // 每页数
- sizeChangeHandle (val) {
- this.pageSize = val
- this.pageIndex = 1
- this.getDataList()
- },
- // 当前页
- currentChangeHandle (val) {
- this.pageIndex = val
- this.getDataList()
- },
- // 多选
- selectionChangeHandle (val) {
- this.dataListSelections = val
- },
- // 新增 / 修改
- addOrUpdateHandle (id, disable) {
- this.addOrUpdateVisible = true
- this.$nextTick(() => {
- this.$refs.addOrUpdate.init(id, disable)
- })
- },
- // 变更
- changeHandle (id) {
- this.changeFormVisible = true
- this.$nextTick(() => {
- this.$refs.changeForm.init(id)
- })
- },
- // 转换属性“物料类别”
- typeFormat (row) {
- if (this.optionsType) {
- for (let i = 0; i < this.optionsType.length; i++) {
- if (this.optionsType[i].code === row.productType) {
- return this.optionsType[i].value
- }
- }
- }
- },
- // 转换属性“是否组合物料”
- composeFormat (row) {
- if (!row.isCompose) return ''
- if (Number(row.isCompose) === 1) {
- return '是'
- } else return '否'
- },
- // 详情
- detailHandle (id) {
- this.detailVisible = true
- this.$nextTick(() => {
- this.$refs.detail.init(id)
- })
- },
- // 变更通知人设置
- setNoticeChangeHandel () {
- this.noticeChangeVisible = true
- this.$nextTick(() => {
- this.$refs.noticeChangeSetting.init()
- })
- },
- // 对应图纸
- drawDetails (row) {
- this.drawVisible = true
- this.$nextTick(() => {
- this.$refs.drawDetail.init(row.proDrawings)
- })
- },
- // 对应工艺
- techDetails (id) {
- this.craftsVisible = true
- this.$nextTick(() => {
- this.$refs.craftsDetail.init(id)
- })
- },
- // 物料更改通知单
- changeDetails (row) {
- this.changeVisible = true
- this.$nextTick(() => {
- this.$refs.changeDetail.init(row.noticeChangeRecord.attachList)
- })
- },
- // 物料技术文件
- attachDetails (row) {
- this.attachVisible = true
- this.$nextTick(() => {
- this.$refs.attachDetail.init(row.attachList)
- })
- },
- // 物料配料清单附件
- attachDetails2 (row) {
- this.attachVisible = true
- this.$nextTick(() => {
- this.$refs.attachDetail.init(row.listingList)
- })
- },
- // 状态
- formatState (row) {
- if (!row.state) return ''
- let option = this.bomStateOption.find(t => t.value === row.state)
- if (option != null) {
- return option.label
- }
- return ''
- },
- formatReadState (row) {
- if (!row.writeState) return ''
- let option = this.writeStateOption.find(t => t.value === row.writeState)
- if (option != null) {
- return option.label
- }
- return ''
- },
- pauseHandle (id) {
- if (!id) return
- this.$confirm(`确定暂停?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/pause`),
- method: 'POST',
- data: {id: id}
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.getDataList()
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }).catch(() => {})
- },
- regainHandle (id) {
- if (!id) return
- this.$confirm(`确定恢复?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/regain`),
- method: 'POST',
- data: {id: id}
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.getDataList()
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }).catch(() => {})
- },
- readHandle (id) {
- if (!id) return
- this.$confirm(`确定只读?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/read`),
- method: 'POST',
- data: {id: id}
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.getDataList()
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }).catch(() => {})
- },
- writeHandle (id) {
- if (!id) return
- this.$confirm(`确定读写?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/write`),
- method: 'POST',
- data: {id: id}
- }).then(({data}) => {
- if (data && data.code === '200') {
- this.$message({
- message: '操作成功',
- type: 'success',
- duration: 1500,
- onClose: () => {
- this.getDataList()
- }
- })
- } else {
- this.$message.error(data.msg)
- }
- })
- }).catch(() => {})
- },
- importFromExcel () {
- this.importVisible = true
- },
- handleUpload (file) {
- if (file == null) {
- this.$message.error('请上传清单文件')
- return
- }
- this.importLoading = true
- const formData = new FormData()
- formData.append('importFile', file.file)
- this.$http({
- url: this.$http.adornUrl(`/biz-service/product/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)
- }
- })
- },
- // 上传
- submitUpload () {
- this.$refs.upload.submit()
- },
- // 移除
- handleRemove (file, fileList) {
- this.$emit('input', fileList)
- },
- templateDownload () {
- location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
- },
- loadingData (row, treeNode, resolve) {
- getChildren(row.productId).then(({data}) => {
- if (data && data.code === '200') {
- data.data.forEach(item => {
- if (item.attachList2 && item.attachList2.length > 0) {
- item.simplePic = downloadUrl + item.attachList2[0].url
- } else {
- item.simplePic = ''
- }
- })
- resolve(data.data)
- } else {
- this.$message.error(data.msg)
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- </style>
|