devicesmgt/sgzb-ui/src/views/store/newBuy/newDevices/newDevicesCode.vue

526 lines
17 KiB
Vue
Raw Normal View History

2023-12-12 13:36:08 +08:00
<template>
2024-05-06 15:21:37 +08:00
<div class="app-container" id="newDevicesCode">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="关键字" prop="keyWord">
<el-input
v-model="queryParams.keyWord"
placeholder="请输入关键字"
clearable
maxlength="50"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
2023-12-12 13:36:08 +08:00
2024-05-06 15:21:37 +08:00
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
2023-12-12 13:36:08 +08:00
2024-05-06 15:21:37 +08:00
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
2023-12-12 13:36:08 +08:00
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
2024-01-14 14:51:21 +08:00
@click="handleAdd"
2023-12-12 13:36:08 +08:00
>新增</el-button>
2024-04-20 12:23:39 +08:00
</el-col>-->
2024-05-06 15:21:37 +08:00
<el-col :span="1.5">
<el-button type="success" plain size="mini" icon="el-icon-back" @click="jumpList">新购验收管理</el-button>
</el-col>
2024-04-20 12:23:39 +08:00
2024-05-06 15:21:37 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2023-12-12 13:36:08 +08:00
2024-05-06 15:21:37 +08:00
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column label="序号" align="center" type="index" />
<el-table-column label="机具类型名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="specificationType" :show-overflow-tooltip="true" />
<el-table-column label="采购时间" align="center" prop="purchaseTime" :show-overflow-tooltip="true" />
<el-table-column label="采购数量" align="center" prop="purchaseNum" :show-overflow-tooltip="true" />
<el-table-column label="验收数量" align="center" prop="checkNum" :show-overflow-tooltip="true" />
<el-table-column label="绑定数量" align="center" prop="bindNum" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.bindNum > 0">{{ scope.row.bindNum }}</span>
<span v-else>0</span>
</template>
</el-table-column>
<el-table-column label="是否为固定资产" align="center" prop="fixCode" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.fixCode == '0'"></span>
<span v-if="scope.row.fixCode == '1'"></span>
</template>
</el-table-column>
<!-- <el-table-column label="编码类型" align="center" prop="codeType" :show-overflow-tooltip="true" />
2024-04-20 12:23:39 +08:00
<el-table-column label="二维码" align="center" prop="dictName" :show-overflow-tooltip="true" />-->
2023-12-19 04:26:18 +08:00
<el-table-column label="状态" align="center" prop="status" width="180">
2023-12-22 18:57:52 +08:00
<template slot-scope="scope">
2024-04-25 16:00:19 +08:00
<span v-if="scope.row.status == 0">待入库</span>
<span v-if="scope.row.status == 1">已入库</span>
2023-12-22 18:57:52 +08:00
</template>
2023-12-12 13:36:08 +08:00
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
icon="el-icon-view"
:disabled="scope.row.bindNum == 0"
@click="handleBindDetails(scope.row)"
>
查看
</el-button>
2023-12-12 13:36:08 +08:00
<el-button
2024-04-20 12:23:39 +08:00
size="mini"
type="primary"
2024-04-25 16:00:19 +08:00
v-if="scope.row.bindNum < scope.row.checkNum"
2024-04-20 12:23:39 +08:00
@click="handleCode(scope.row)"
2024-04-25 16:00:19 +08:00
>
绑定编码
</el-button>
2023-12-12 13:36:08 +08:00
</template>
</el-table-column>
</el-table>
2024-04-20 12:23:39 +08:00
<!--
2023-12-12 13:36:08 +08:00
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
2024-04-20 12:23:39 +08:00
/>-->
2023-12-12 13:36:08 +08:00
<!-- 添加或修改参数配置对话框 -->
2024-04-25 16:00:19 +08:00
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body :close-on-click-modal="false">
2023-12-21 20:24:30 +08:00
<el-row :gutter="24" class="mb8">
<el-form ref="form" :model="form" :rules="rules" label-width="78px" v-if="!isDetail">
2024-04-20 12:23:39 +08:00
<el-input v-model="form.typeId" disabled v-show="false" />
2023-12-21 20:24:30 +08:00
<el-col :span="7">
<el-form-item label="编码前缀" prop="exCode">
2024-04-20 12:23:39 +08:00
<el-input v-model="form.exCode" @change="fillingCodeList" />
2023-12-21 20:24:30 +08:00
</el-form-item>
</el-col>
<el-col :span="7">
2023-12-23 16:03:15 +08:00
<el-form-item label="后缀范围">
2024-04-25 16:00:19 +08:00
<div style="display: flex">
<el-input v-model="form.str" placeholder="0001" maxlength="4" @change="fillingCodeList"></el-input>
-
<el-input v-model="form.str1" placeholder="0005" maxlength="4" @change="fillingCodeList"></el-input>
2024-04-20 12:23:39 +08:00
</div>
2023-12-21 20:24:30 +08:00
</el-form-item>
</el-col>
<el-col :span="6">
2023-12-23 19:42:57 +08:00
<el-form-item label="固定资产" prop="fixCode">
2024-04-20 12:23:39 +08:00
<el-select
v-model="form.fixCode"
placeholder="是否为固定资产"
@change="fillingCodeList"
clearable
allow-create
>
<el-option label="是" value="0" />
<el-option label="否" value="1" />
2023-12-21 20:24:30 +08:00
</el-select>
</el-form-item>
</el-col>
2023-12-22 18:57:52 +08:00
<!-- <el-col :span="2">
2023-12-21 20:24:30 +08:00
<el-button
type="primary"
plain
size="mini"
@click="createCodeList"
>生成</el-button>
2024-04-20 12:23:39 +08:00
</el-col>-->
2023-12-21 20:24:30 +08:00
<el-col :span="2">
2024-04-20 12:23:39 +08:00
<el-button type="primary" plain size="mini" @click="fillingCodeList">填充</el-button>
2023-12-21 20:24:30 +08:00
</el-col>
</el-form>
</el-row>
<el-table v-loading="loading" :data="codeList" height="400">
2024-04-20 12:23:39 +08:00
<!-- <el-table-column type="selection" width="50" align="center" /> -->
<el-table-column label="序号" align="center" type="index" />
2024-04-25 16:00:19 +08:00
<el-table-column label="机具种类" align="center" prop="typeName" :show-overflow-tooltip="true" width="120" />
2024-04-20 12:23:39 +08:00
<el-table-column
label="规格型号"
align="center"
prop="specificationType"
:show-overflow-tooltip="true"
width="120"
/>
<el-table-column label="设备编码" align="center" prop="maCode" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-input
v-if="!isDetail"
2024-04-20 12:23:39 +08:00
v-model="scope.row.maCode"
2024-04-25 16:00:19 +08:00
:disabled="scope.row.statusFlag == 0"
2024-04-20 12:23:39 +08:00
οninput="value=value.replace(/[^0-9.]/g,'')"
></el-input>
<span v-else>{{ scope.row.maCode }}</span>
2024-04-20 12:23:39 +08:00
</template>
</el-table-column>
<el-table-column label="固定资产编码" align="center" prop="assetsCode">
<template slot-scope="scope">
<el-input v-model="scope.row.assetsCode" v-if="!isDetail" v-show="form.fixCode == '0'" maxlength="50"></el-input>
<span v-else>{{ scope.row.assetsCode }}</span>
2024-04-20 12:23:39 +08:00
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width" v-if="!isDetail">
2024-04-20 12:23:39 +08:00
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="delCode(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
2023-12-21 20:24:30 +08:00
2023-12-12 13:36:08 +08:00
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button type="primary" @click="submitForm" v-if="!isDetail"> </el-button>
2023-12-12 13:36:08 +08:00
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
2024-04-20 12:23:39 +08:00
import { listType, getType, delType, addType, updateType, refreshCache } from '@/api/system/dict/type'
import {
getPurchaseCheckInfo,
listPurchaseMacodeInfo,
addPurchaseMacode,
updateMacode,
delMacode,
getMacodeInfo,
} from '@/api/store/newBuy'
import {
getMacodeList,
getMacodeDetailList,
makeEquipmentNumber,
editPurchaseMacode,
delMacodeList,
getBindCodeDetails
2024-04-20 12:23:39 +08:00
} from '@/api/store/newBuy'
2023-12-19 04:26:18 +08:00
2024-05-06 15:21:37 +08:00
import { getTypeList } from '@/api/store/warehousing'
import { getListByMaType } from '@/api/store/tools'
import { number } from 'echarts'
2023-12-12 13:36:08 +08:00
export default {
2024-04-20 12:23:39 +08:00
name: 'NewDevicesCode',
2023-12-12 13:36:08 +08:00
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
2023-12-19 04:26:18 +08:00
typeList: [],
modelList: [],
2023-12-12 13:36:08 +08:00
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
2024-04-20 12:23:39 +08:00
taskId: '',
2023-12-21 20:24:30 +08:00
// 表格数据
typeList: [],
2023-12-12 13:36:08 +08:00
// 弹出层标题
2024-04-20 12:23:39 +08:00
title: '',
2023-12-12 13:36:08 +08:00
// 是否显示弹出层
open: false,
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
2023-12-21 20:24:30 +08:00
// pageNum: 1,
// pageSize: 10,
typeName: undefined,
2023-12-12 13:36:08 +08:00
},
// 表单参数
2023-12-21 20:24:30 +08:00
form: {
2024-04-20 12:23:39 +08:00
exCode: '',
str: '',
str1: '',
fixCode: '1',
typeId: '',
2023-12-21 20:24:30 +08:00
},
2024-04-20 12:23:39 +08:00
codeList: [], //弹窗列表list
getCodeList: [], //已成过的编码list
newCodeList: [], //新的编码list
2023-12-12 13:36:08 +08:00
// 表单校验
rules: {
2023-12-21 20:24:30 +08:00
// typeId: [
// { required: true, message: "机具类型名称不能为空", trigger: "blur" }
// ],
// modelId: [
// { required: true, message: "规格型号不能为空", trigger: "blur" }
// ],
// maCode: [
// { required: true, message: "设备编号不能为空", trigger: "blur" }
// ],
2024-04-20 12:23:39 +08:00
},
isDetail: false,
2024-04-20 12:23:39 +08:00
}
2023-12-12 13:36:08 +08:00
},
2024-04-20 14:29:59 +08:00
mounted() {
2024-04-25 16:00:19 +08:00
const taskId = this.$route.query && this.$route.query.taskId
this.taskId = taskId
// console.log(this.taskId)
2024-04-20 12:23:39 +08:00
this.getList()
2023-12-12 13:36:08 +08:00
},
methods: {
2023-12-21 20:24:30 +08:00
//获取类型数据
2023-12-19 04:26:18 +08:00
getTypeList() {
2024-04-20 12:23:39 +08:00
getTypeList({ level: '3' }).then(response => {
this.typeList = response.data
})
2023-12-19 04:26:18 +08:00
},
selectType(id) {
console.log(id)
2024-04-20 12:23:39 +08:00
getListByMaType({ typeId: id }).then(response => {
this.modelList = response.data
})
2023-12-19 04:26:18 +08:00
},
2023-12-21 20:24:30 +08:00
/** 查询列表 */
2024-04-25 16:00:19 +08:00
async getList() {
2024-04-20 12:23:39 +08:00
this.loading = true
2023-12-19 04:26:18 +08:00
this.queryParams.taskId = this.taskId
2024-04-25 16:00:19 +08:00
const { data: res } = await getMacodeList(this.queryParams)
2024-04-26 17:51:49 +08:00
this.typeList = res
2024-04-25 16:00:19 +08:00
this.loading = false
2023-12-12 13:36:08 +08:00
},
// 取消按钮
cancel() {
2024-04-20 12:23:39 +08:00
this.reset()
this.open = false
2023-12-12 13:36:08 +08:00
},
// 表单重置
reset() {
this.form = {
2023-12-23 16:03:15 +08:00
str: undefined,
str1: undefined,
2024-04-20 12:23:39 +08:00
fixCode: '1',
}
this.resetForm('form')
2023-12-12 13:36:08 +08:00
},
/** 搜索按钮操作 */
handleQuery() {
2024-04-20 12:23:39 +08:00
this.queryParams.pageNum = 1
this.getList()
2023-12-12 13:36:08 +08:00
},
/** 重置按钮操作 */
resetQuery() {
2024-04-20 12:23:39 +08:00
this.dateRange = []
this.resetForm('queryForm')
this.handleQuery()
2023-12-12 13:36:08 +08:00
},
/** 新增按钮操作 */
handleAdd() {
2024-04-20 12:23:39 +08:00
this.reset()
this.open = true
this.title = '添加'
2023-12-12 13:36:08 +08:00
},
// 多选框选中数据
handleSelectionChange(selection) {
2023-12-19 04:26:18 +08:00
this.ids = selection.map(item => item.maId)
2024-04-20 12:23:39 +08:00
this.single = selection.length != 1
2023-12-12 13:36:08 +08:00
this.multiple = !selection.length
2024-04-20 12:23:39 +08:00
}, //getCodeList newCodeList
/** 编码按钮操作 */ handleCode(row) {
2023-12-21 20:24:30 +08:00
console.log(row)
2023-12-23 16:03:15 +08:00
this.reset()
2024-04-20 12:23:39 +08:00
this.form = row
this.$set(this.form, 'str', '')
this.$set(this.form, 'str1', '')
2023-12-23 21:41:58 +08:00
// this.$set(this.form,'fixCode','1')
2024-04-20 12:23:39 +08:00
let arr = this.form.arrivalTime.split('-')
2023-12-23 21:41:58 +08:00
// this.form.exCode = ;
2024-04-08 09:01:54 +08:00
// this.form.typeCode=111
2024-04-20 12:23:39 +08:00
if (!this.form.typeCode) {
this.form.typeCode = ''
2024-04-08 09:01:54 +08:00
}
2024-04-20 12:23:39 +08:00
if (!this.form.specsCode) {
this.form.specsCode = ''
2024-04-08 09:01:54 +08:00
}
2024-04-20 12:23:39 +08:00
this.$set(this.form, 'exCode', 'NSJJ' + this.form.typeCode + this.form.specsCode + arr[0][2] + arr[0][3] + arr[1])
this.form.count = row.checkNum
this.codeList = []
this.open = true
this.title = '生成编码'
this.isDetail = false
2023-12-22 18:57:52 +08:00
// let param = {
// taskId:this.taskId,
// typeId:row.typeId,
// }
// getMacodeDetailList(param).then(response => {
// this.codeList = response.data;
2024-04-20 12:23:39 +08:00
2023-12-22 18:57:52 +08:00
// });
2023-12-21 20:24:30 +08:00
},
//生成列表codeList
2024-04-20 12:23:39 +08:00
createCodeList() {
2023-12-23 16:03:15 +08:00
// if(this.codeList.length>=this.form.checkNum){
// this.$modal.msgError("生成编码数量不可超过采购验收数量!!!");
// }else{
// for(let i = 0; i < this.form.count; i++) {
// let obj = {
// typeName:this.form.typeName,
// specificationType:this.form.specificationType,
// typeId: this.form.typeId,
// taskId: this.form.taskId,
// assetsCode:'',
2023-12-23 19:42:57 +08:00
// fixCode:this.form.fixCode,
2023-12-23 16:03:15 +08:00
// }
// this.newCodeList.push(obj)
// }
// console.log(this.newCodeList,'this.newCodeList')
// this.codeList = this.getCodeList.concat(this.newCodeList)
// }
2023-12-12 13:36:08 +08:00
},
2023-12-21 20:24:30 +08:00
//填充按钮
2024-04-20 12:23:39 +08:00
fillingCodeList() {
2023-12-22 18:57:52 +08:00
console.log(Number(this.form.str))
this.codeList = []
let num = Number(this.form.str)
2023-12-23 16:03:15 +08:00
// console.log(Number(this.form.str1))
2023-12-22 18:57:52 +08:00
let num1 = Number(this.form.str1)
2024-04-20 12:23:39 +08:00
let count = num1 - num + 1 //生成数量
2023-12-23 16:03:15 +08:00
console.log()
2024-04-20 12:23:39 +08:00
let sum = count + this.form.bindNum
2023-12-22 18:57:52 +08:00
console.log(sum)
2024-04-20 12:23:39 +08:00
if (sum > this.form.checkNum) {
this.$modal.msgError('已绑定编码' + this.form.bindNum + '个,总数量已超过验收数量,请调整后缀范围。')
} else {
if (num1 => num) {
for (let i = 0; i < count; i++) {
let obj = {
typeName: this.form.typeName,
specificationType: this.form.specificationType,
typeId: this.form.typeId,
taskId: this.form.taskId,
maCode: this.form.exCode + ('00000' + (num + i)).slice(-4),
assetsCode: '',
fixCode: this.form.fixCode,
2024-04-26 14:45:18 +08:00
}
2024-05-06 15:21:37 +08:00
this.codeList.push(obj)
}
} else {
this.$modal.msgError('编码后缀范围输入格式不正确')
}
}
},
/** 提交按钮 */
submitForm: function () {
// console.log(this.codeList)
if (this.form.fixCode == 0) {
if (this.hasDuplicateField(this.codeList, 'assetsCode')) {
this.$modal.msgError('固定资产编码不能为空')
return false
}
}
if (this.codeList.length == 0) {
this.$modal.msgError('无新增编码绑定')
} else {
const maCodeSet = new Set()
let hasDuplicates = false
for (const item of this.codeList) {
const maCode = item.maCode
if (maCodeSet.has(maCode)) {
hasDuplicates = true
break
}
maCodeSet.add(maCode)
}
console.log('codeList:', this.codeList)
if (hasDuplicates) {
this.$modal.msgError('编码绑定失败,存在重复编码,请重新输入')
return // 停止提交流程
}
editPurchaseMacode(this.codeList).then(response => {
console.log(this.codeList)
if (response.data && response.data.length > 0) {
this.codeList = response.data
this.$modal.msgError('编码绑定失败,存在重复编码,请重新输入')
} else {
this.$modal.msgSuccess('编码绑定成功')
this.open = false
2024-04-26 14:45:18 +08:00
this.getList()
2023-12-23 16:03:15 +08:00
}
2024-04-20 12:23:39 +08:00
})
2023-12-21 20:24:30 +08:00
}
2024-04-10 17:04:07 +08:00
},
hasDuplicateField(array, field) {
2024-04-20 12:23:39 +08:00
const map = {}
2024-04-10 17:04:07 +08:00
for (let i = 0; i < array.length; i++) {
2024-04-20 12:23:39 +08:00
const value = array[i][field]
2024-04-10 17:04:07 +08:00
if (map[value]) {
2024-04-20 12:23:39 +08:00
return true
2024-04-10 17:04:07 +08:00
}
2024-04-20 12:23:39 +08:00
map[value] = true
2024-04-10 17:04:07 +08:00
}
2024-04-20 12:23:39 +08:00
return false
2023-12-21 20:24:30 +08:00
},
2024-04-20 12:23:39 +08:00
getdetailmaCodeList(data) {
2023-12-21 20:24:30 +08:00
console.log(data)
let param = {
2024-04-20 12:23:39 +08:00
taskId: this.taskId,
typeId: data.typeId,
}
2023-12-21 20:24:30 +08:00
getMacodeDetailList(param).then(response => {
2024-04-20 12:23:39 +08:00
this.getCodeList = response.data
this.codeList = this.getCodeList.concat(this.newCodeList)
})
2023-12-21 20:24:30 +08:00
},
delCode(row) {
2023-12-23 16:03:15 +08:00
console.log(row)
2024-04-20 12:23:39 +08:00
this.codeList.forEach((item, index) => {
if (item.maCode == row.maCode) {
this.codeList.splice(index, 1)
2023-12-23 16:03:15 +08:00
}
2024-04-20 12:23:39 +08:00
})
2023-12-23 16:03:15 +08:00
// const maCode = row.maCode ;
// this.$modal.confirm('是否确认删除该数据项?').then(function() {
// return delMacodeList(maCode);
// }).then(() => {
// this.getdetailmaCodeList(row);
// this.$modal.msgSuccess("删除成功");
// }).catch(() => {});
2023-12-19 04:26:18 +08:00
},
2024-04-20 12:23:39 +08:00
// 返回列表页
jumpList() {
const obj = { path: '/store/newBuy/newDevicesList' }
this.$tab.closeOpenPage(obj)
2023-12-12 13:36:08 +08:00
},
async handleBindDetails(row) {
console.log('🚀 ~ handleBindDetails ~ row:', row.taskId);
this.open = true
this.isDetail = true
this.title = '编码绑定详情'
this.codeList = []
const res = await getBindCodeDetails({taskId: row.taskId})
console.log('🚀 ~ handleBindDetails ~ res:', res);
this.codeList = res.data
2024-04-26 14:45:18 +08:00
}
2024-04-20 12:23:39 +08:00
},
}
2023-12-12 13:36:08 +08:00
</script>
2023-12-22 18:57:52 +08:00
<style scoped>
2024-05-06 15:21:37 +08:00
.redColor {
color: red;
}
2023-12-22 18:57:52 +08:00
</style>
2024-01-12 10:07:35 +08:00
<style lang="scss" scoped>
2024-05-06 15:21:37 +08:00
::v-deep.el-table .fixed-width .el-button--mini {
width: 60px !important;
margin-bottom: 10px;
}
2024-04-25 16:00:19 +08:00
</style>