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

469 lines
15 KiB
Vue
Raw Normal View History

2023-12-12 13:36:08 +08:00
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
2023-12-21 20:24:30 +08:00
<el-form-item label="名称" prop="typeName">
2023-12-12 13:36:08 +08:00
<el-input
2023-12-21 20:24:30 +08:00
v-model="queryParams.typeName"
2023-12-12 13:36:08 +08:00
placeholder="请输入名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<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>
<el-row :gutter="10" class="mb8">
2023-12-21 20:24:30 +08:00
<!-- <el-col :span="1.5">
2023-12-12 13:36:08 +08:00
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['store:labelType:add']"
>新增</el-button>
2023-12-21 20:24:30 +08:00
</el-col> -->
2023-12-19 04:26:18 +08:00
<el-col :span="1.5">
<el-button
type="primary"
plain
size="mini"
@click="jumpList"
>采购验收管理</el-button>
</el-col>
2023-12-21 20:24:30 +08:00
2023-12-19 04:26:18 +08:00
2023-12-12 13:36:08 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2023-12-21 20:24:30 +08:00
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" align="center" /> -->
2023-12-19 04:26:18 +08:00
<el-table-column label="序号" align="center" type="index" />
2023-12-21 20:24:30 +08:00
<el-table-column label="机具类型名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
2023-12-19 04:26:18 +08:00
<el-table-column label="规格型号" align="center" prop="specificationType" :show-overflow-tooltip="true" />
2023-12-21 20:24:30 +08:00
<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>
2023-12-19 04:26:18 +08:00
<el-table-column label="是否为固定资产" align="center" prop="fixCode" :show-overflow-tooltip="true" >
2023-12-21 20:24:30 +08:00
<template slot-scope="scope">
<span v-if="scope.row.fixCode == '0'"></span>
<span v-if="scope.row.fixCode == '1'"></span>
</template>
2023-12-19 04:26:18 +08:00
</el-table-column>
2023-12-21 20:24:30 +08:00
<!-- <el-table-column label="编码类型" align="center" prop="codeType" :show-overflow-tooltip="true" />
<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-21 20:24:30 +08:00
<!-- <template slot-scope="scope">
2023-12-19 04:26:18 +08:00
<span v-if="scope.row.status==0">删除</span>
<span v-if="scope.row.status==1">正常</span>
2023-12-21 20:24:30 +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"
type="text"
icon="el-icon-edit"
2023-12-21 20:24:30 +08:00
@click="handleCode(scope.row)"
>绑定编码</el-button>
<!-- <el-button
2023-12-12 13:36:08 +08:00
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
2023-12-21 20:24:30 +08:00
>删除</el-button> -->
2023-12-12 13:36:08 +08:00
</template>
</el-table-column>
</el-table>
2023-12-21 20:24:30 +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"
2023-12-21 20:24:30 +08:00
/> -->
2023-12-12 13:36:08 +08:00
<!-- 添加或修改参数配置对话框 -->
2023-12-21 20:24:30 +08:00
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-row :gutter="24" class="mb8">
<el-form ref="form" :model="form" :rules="rules" label-width="78px">
<el-input v-model="form.typeId" disabled v-show="false"/>
<el-col :span="7">
<el-form-item label="编码前缀" prop="exCode">
<el-input v-model="form.exCode" :readonly="true"/>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="生成数量" prop="count">
<el-input-number controls-position="right" v-model="form.count" type="number" :min="1" placeholder="请输入编码生成数量" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="固定资产" prop="isFixed">
<el-select v-model="form.isFixed" placeholder="是否为固定资产" clearable allow-create="">
<el-option label="是" value="0"/>
<el-option label="否" value="1"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="2">
<el-button
type="primary"
plain
size="mini"
@click="createCodeList"
>生成</el-button>
</el-col>
<el-col :span="2">
<el-button
type="primary"
plain
size="mini"
@click="fillingCodeList"
>填充</el-button>
</el-col>
</el-form>
</el-row>
<el-table v-loading="loading" :data="codeList" height="400">
<!-- <el-table-column type="selection" width="50" 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="maCode" :show-overflow-tooltip="true" />
<el-table-column label="固定资产编码" align="center" prop="assetsCode" width="120" />
<el-table-column
label="操作"
align="center"
width="160"
class-name="small-padding fixed-width"
2023-12-19 04:26:18 +08:00
>
2023-12-21 20:24:30 +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-12 13:36:08 +08:00
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
2023-12-21 20:24:30 +08:00
2023-12-12 13:36:08 +08:00
</div>
</template>
<script>
import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
2023-12-21 20:24:30 +08:00
import { getPurchaseCheckInfo, listPurchaseMacodeInfo,addPurchaseMacode,updateMacode,delMacode,getMacodeInfo, } from "@/api/store/newBuy";
import { getMacodeList,getMacodeDetailList,makeEquipmentNumber,editPurchaseMacode,delMacodeList } from "@/api/store/newBuy";
2023-12-19 04:26:18 +08:00
import { getTypeList } from "@/api/store/warehousing";
import { getListByMaType } from "@/api/store/tools";
2023-12-12 13:36:08 +08:00
export default {
name: "Dict",
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,
2023-12-19 04:26:18 +08:00
taskId:'',
2023-12-21 20:24:30 +08:00
// 表格数据
typeList: [],
2023-12-12 13:36:08 +08:00
// 弹出层标题
title: "",
// 是否显示弹出层
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: {
exCode:'NXJJ',
count:1,
isFixed:'1',
typeId:''
},
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" }
// ],
2023-12-12 13:36:08 +08:00
}
};
},
created() {
2023-12-19 04:26:18 +08:00
const taskId = this.$route.query && this.$route.query.taskId;
this.taskId = taskId;
console.log(this.taskId)
2023-12-12 13:36:08 +08:00
this.getList();
},
methods: {
2023-12-21 20:24:30 +08:00
//获取类型数据
2023-12-19 04:26:18 +08:00
getTypeList() {
getTypeList({level:'3'}).then(response => {
this.typeList = response.data;
}
);
},
selectType(id) {
console.log(id)
getListByMaType({typeId:id}).then(response => {
this.modelList = response.data;
}
);
},
2023-12-21 20:24:30 +08:00
/** 查询列表 */
2023-12-12 13:36:08 +08:00
getList() {
this.loading = true;
2023-12-19 04:26:18 +08:00
this.queryParams.taskId = this.taskId
2023-12-21 20:24:30 +08:00
getMacodeList(this.queryParams).then(response => {
this.typeList = response.data;
2023-12-12 13:36:08 +08:00
this.loading = false;
}
);
},
// 取消按钮
cancel() {
this.open = false;
},
// 表单重置
reset() {
this.form = {
2023-12-19 04:26:18 +08:00
maId: undefined,
2023-12-12 13:36:08 +08:00
dictName: undefined,
dictType: undefined,
status: "0",
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加";
},
// 多选框选中数据
handleSelectionChange(selection) {
2023-12-19 04:26:18 +08:00
this.ids = selection.map(item => item.maId)
2023-12-12 13:36:08 +08:00
this.single = selection.length!=1
this.multiple = !selection.length
},
2023-12-21 20:24:30 +08:00
/** 编码按钮操作 */ //getCodeList newCodeList
handleCode(row) {
console.log(row)
let param = {
taskId:this.taskId,
typeId:row.typeId,
}
this.newCodeList = [];
getMacodeDetailList(param).then(response => {
this.getCodeList = response.data;
this.codeList = this.getCodeList.concat(this.newCodeList)
2023-12-12 13:36:08 +08:00
this.open = true;
2023-12-21 20:24:30 +08:00
this.title = "生成编码";
2023-12-12 13:36:08 +08:00
});
2023-12-21 20:24:30 +08:00
this.form = row
// this.form.count = row.checkNum;
this.form.count = row.checkNum;
this.form.typeId = row.typeId;
this.form.taskId = row.taskId;
this.form.isFixed = '1';
this.form.exCode = 'NXJJ'+this.form.typeCode+this.form.specsCode;
// this.open = true;
// this.title = "生成编码";
},
//生成列表codeList
createCodeList(){
// console.log(this.form.checkNum)
// console.log(this.codeList.length)
// console.log(this.newCodeList)
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:'',
isFixed:this.form.isFixed,
}
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
//填充按钮
fillingCodeList(){
// console.log(this.form.checkNum)
// console.log(this.getCodeList,'getCodeList')
// console.log(this.newCodeList,'newCodeList')
// console.log(this.codeList)
// let emptyNum = 0;
// for(let i = 0; i < this.codeList.length; i++) {
// if(!this.codeList.maCode || this.codeList.maCode==''){
// emptyNum = emptyNum+1;
// }
// };
// console.log(emptyNum,'emptyNum')
if(this.newCodeList.length>0){
let param = {
"typeId": this.form.typeId,
"count": this.newCodeList.length
}
makeEquipmentNumber(param).then(response => {
// this.newCodeList.forEach((item,index) => {
// this.$set(item,'maCode',response.data.equipmentNum);
// });
response.data.equipmentNum.forEach((item,index) => {
this.$set(this.newCodeList[index], 'maCode', item);
// this.newCodeList[index].maCode = item
});
console.log(this.newCodeList)
this.codeList = this.getCodeList.concat(this.newCodeList)
// response.equipmentNum
});
}else{
this.$modal.msgError("已全部绑定过设备编码");
}
},
2023-12-12 13:36:08 +08:00
/** 提交按钮 */
submitForm: function() {
2023-12-21 20:24:30 +08:00
console.log(this.newCodeList)
if(this.newCodeList.length==0){
this.$modal.msgError("无新增编码绑定");
}else{
editPurchaseMacode(this.newCodeList).then(response => {
this.$modal.msgSuccess("绑定成功");
this.open = false;
this.getList();
});
}
},
getdetailmaCodeList(data){
console.log(data)
let param = {
taskId:this.taskId,
typeId:data.typeId,
}
getMacodeDetailList(param).then(response => {
this.getCodeList = response.data;
this.codeList = this.getCodeList.concat(this.newCodeList)
2023-12-12 13:36:08 +08:00
});
2023-12-21 20:24:30 +08:00
},
delCode(row) {
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
},
// 返回列表页
jumpList(){
const obj = { path: "/store/newBuy/newDevicesList" }
this.$tab.closeOpenPage(obj);
2023-12-12 13:36:08 +08:00
},
/** 删除按钮操作 */
handleDelete(row) {
2023-12-19 04:26:18 +08:00
const dictIds = row.maId ;
2023-12-12 13:36:08 +08:00
this.$modal.confirm('是否确认删除该数据项?').then(function() {
2023-12-19 04:26:18 +08:00
return delMacode(dictIds);
2023-12-12 13:36:08 +08:00
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/dict/type/export', {
...this.queryParams
}, `type_${new Date().getTime()}.xlsx`)
},
/** 刷新缓存按钮操作 */
handleRefreshCache() {
refreshCache().then(() => {
this.$modal.msgSuccess("刷新成功");
this.$store.dispatch('dict/cleanDict');
});
}
}
};
</script>