This commit is contained in:
2024-10-16 09:55:22 +08:00
parent 9fc6f013cc
commit 9699e90ab3
21 changed files with 1621 additions and 829 deletions

View File

@@ -37,12 +37,14 @@
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm
<DialogFormZ
v-if="open"
ref="form"
v-model="form"
label-position="top"
:disabled="mode == 'detail'"
:has-files="false"
@selectupdate="updateDialogFormZ"
:rows="rows" />
</base-dialog>
</div>
@@ -51,14 +53,16 @@
<script>
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import DialogFormZ from '../../../DialogFormZ.vue';
import { publicFormatter } from '@/utils/dict';
import { deleteSparePart } from '@/api/equipment/base/spare-parts/list';
import { getMaterialTree, getMaterialList } from '@/api/base/material';
const timeFilter = (val) => moment(val).format('yyyy-MM-DD HH:mm:ss');
export default {
name: 'EquipmentSparePartsList',
components: {},
components: { DialogFormZ },
mixins: [basicPageMixin],
data() {
return {
@@ -129,33 +133,44 @@ export default {
rows: [
[
{
input: true,
select: true,
label: '备件名称',
prop: 'name',
prop: 'productMaterialId',
options: [],
bind: {
filterable: true,
clearable: false,
},
rules: [
{ required: true, message: '备件名称不能为空', trigger: 'blur' },
{
required: true,
message: '备件名称不能为空',
trigger: 'change',
},
],
},
{
input: true,
label: '备件编码',
prop: 'code',
url: '/base/equipment-spare-part/getCode',
rules: [
{ required: true, message: '备件编码不能为空', trigger: 'blur' },
],
},
],
[
{
input: true,
label: '备件型号',
prop: 'model',
},
],
[
{
input: true,
label: '备件编码',
prop: 'code',
bind: {
disabled: true,
},
},
{
input: true,
label: '规格',
prop: 'specifications',
bind: {
disabled: true,
},
},
],
[
@@ -165,27 +180,32 @@ export default {
prop: 'supplierId',
url: '/base/core-supplier/listAll', // TODO: 供应商
bind: {
filterable: true,
clearable: true,
disabled: true,
},
rules: [
{ required: true, message: '供应商不能为空', trigger: 'blur' },
],
},
{
select: true,
label: '物料类型',
prop: 'type',
options: this.getDictDatas('material_type'),
// url: '/base/core-equipment/listAll', // TODO: 物料
label: '单位',
prop: 'unit', // 数据字典
bind: {
filterable: true,
clearable: true,
disabled: true,
},
rules: [
{ required: true, message: '物料类型不能为空', trigger: 'blur' },
],
options: this.getDictDatas(this.DICT_TYPE.UNIT_DICT),
},
// {
// select: true,
// label: '物料类型',
// prop: 'type',
// options: this.getDictDatas('material_type'),
// // url: '/base/core-equipment/listAll', // TODO: 物料
// bind: {
// filterable: true,
// clearable: true,
// },
// rules: [
// { required: true, message: '物料类型不能为空', trigger: 'blur' },
// ],
// },
],
[
{
@@ -201,14 +221,6 @@ export default {
},
],
},
{
select: true,
label: '单位',
prop: 'unit', // 数据字典
options: this.getDictDatas(this.DICT_TYPE.UNIT_DICT),
},
],
[
{
input: true,
label: '备注',
@@ -225,11 +237,23 @@ export default {
name: null,
},
// 表单参数
form: {},
form: {
id: null,
code: null,
name: null,
model: null,
specifications: null,
life: null,
type: null,
supplierId: null,
unit: null,
remark: null,
},
basePath: '/base/equipment-spare-part',
mode: null,
};
},
mounted() {},
created() {
// this.initSearchBar();
this.getList();
@@ -267,8 +291,8 @@ export default {
reset() {
this.form = {
id: null,
productMaterialId: null,
code: null,
name: null,
model: null,
specifications: null,
life: null,
@@ -294,6 +318,7 @@ export default {
this.reset();
this.open = true;
this.title = '添加备品备件';
this.getDict();
},
/** 修改按钮操作 */
handleUpdate(row) {
@@ -302,13 +327,14 @@ export default {
this.info({ id }).then((response) => {
this.form = response.data;
if (this.form.unit !== undefined) {
this.form.unit = String(this.form.unit)
this.form.unit = String(this.form.unit);
}
if (this.form.type !== undefined) {
this.form.type = String(this.form.type)
this.form.type = String(this.form.type);
}
this.open = true;
this.title = '修改备品备件';
this.getDict();
});
},
/** 提交按钮 */
@@ -355,6 +381,7 @@ export default {
this.form = response.data;
this.open = true;
this.title = '修改备品备件';
this.getDict();
});
},
/** 导出按钮操作 */
@@ -375,6 +402,30 @@ export default {
})
.catch(() => {});
},
async getDict() {
const materRes = await getMaterialTree(); //
let typeId = materRes.data.find((item) => item.product === 2).id;
const listQuery = {
typeId: typeId,
};
const materData = await getMaterialList(listQuery);
this.rows[0][0].options = (materData.data || []).map((item) => ({
label: item.name,
value: item.id,
...item
}));
},
updateDialogFormZ(val) {
const selectData = this.rows[0][0].options.find(
(item) => item.id === val.productMaterialId
);
this.form.productMaterialId = selectData.id;
this.form.name = selectData.name;
this.form.code = selectData.code;
this.form.specifications = selectData.specifications;
this.form.supplierId = selectData.supplierId;
this.form.unit = selectData.unit;
},
},
};
</script>