add 设备表、产品表 & 同步DialogJustForm到DialogWithMenu
This commit is contained in:
parent
cb3e47a45e
commit
9ccc8b44b3
@ -162,8 +162,6 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
col.options.splice(0);
|
col.options.splice(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return col;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,130 +1,82 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
class="dialog-with-menu"
|
class="dialog-with-menu"
|
||||||
:visible="selfVisible"
|
:visible="selfVisible"
|
||||||
@close="handleClose"
|
@closed="resetForm"
|
||||||
:distory-on-close="true"
|
:distory-on-close="true"
|
||||||
>
|
:close-on-click-modal="configs.clickModalToClose ?? true"
|
||||||
<!-- title -->
|
>
|
||||||
<div slot="title" class="dialog-title">
|
<!-- title -->
|
||||||
<h1 class="">
|
<div slot="title" class="dialog-title">
|
||||||
{{ detailMode ? "查看详情" : dataForm.id ? "编辑" : "新增" }}
|
<h1 class="">
|
||||||
</h1>
|
{{ detailMode ? "查看详情" : dataForm.id ? "编辑" : "新增" }}
|
||||||
</div>
|
</h1>
|
||||||
<!-- menu -->
|
</div>
|
||||||
<el-tabs v-model="activeMenu" type="card" @tab-click="handleTabClick">
|
<!-- menu -->
|
||||||
<!-- <el-tab-pane v-for="(tab, index) in configs.menu" :key="index" :label="tab.name" :name="tab.name"> -->
|
<el-tabs v-model="activeMenu" type="card" @tab-click="handleTabClick">
|
||||||
<el-tab-pane
|
<!-- <el-tab-pane v-for="(tab, index) in configs.menu" :key="index" :label="tab.name" :name="tab.name"> -->
|
||||||
v-for="(tab, index) in actualMenus"
|
<el-tab-pane v-for="(tab, index) in actualMenus" :key="index" :label="tab.name" :name="tab.name">
|
||||||
:key="index"
|
<div v-if="index === 0">
|
||||||
:label="tab.name"
|
<!-- form -->
|
||||||
:name="tab.name"
|
<el-form ref="dataForm" :model="dataForm" v-loading="loadingStatus">
|
||||||
>
|
<el-row v-for="(row, rowIndex) in configs.form.rows" :key="'row_' + rowIndex" :gutter="20">
|
||||||
<div v-if="index === 0">
|
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length">
|
||||||
<!-- form -->
|
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules || null">
|
||||||
<el-form ref="dataForm" :model="dataForm">
|
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="detailMode" v-bind="col.elparams" />
|
||||||
<el-row
|
<el-select
|
||||||
v-for="(row, rowIndex) in configs.form.rows"
|
v-if="col.select"
|
||||||
:key="'row_' + rowIndex"
|
v-model="dataForm[col.prop]"
|
||||||
:gutter="20"
|
clearable
|
||||||
>
|
:disabled="detailMode"
|
||||||
<el-col
|
v-bind="col.elparams"
|
||||||
v-for="(col, colIndex) in row"
|
@change="handleSelectChange(col, $event)"
|
||||||
:key="colIndex"
|
>
|
||||||
:span="24 / row.length"
|
<el-option v-for="(opt, optIdx) in col.options" :key="'option_' + optIdx" :label="opt.label" :value="opt.value" />
|
||||||
>
|
</el-select>
|
||||||
<el-form-item
|
<el-switch
|
||||||
:label="col.label"
|
v-if="col.switch"
|
||||||
:prop="col.prop"
|
v-model="dataForm[col.prop]"
|
||||||
:rules="col.rules || null"
|
:active-value="1"
|
||||||
>
|
:inactive-value="0"
|
||||||
<el-input
|
@change="handleSwitchChange"
|
||||||
v-if="col.input"
|
:disabled="detailMode"
|
||||||
v-model="dataForm[col.prop]"
|
/>
|
||||||
clearable
|
<el-input v-if="col.textarea" type="textarea" v-model="dataForm[col.prop]" :disabled="detailMode" v-bind="col.elparams" />
|
||||||
:disabled="detailMode"
|
<!-- add more... -->
|
||||||
v-bind="col.elparams"
|
</el-form-item>
|
||||||
/>
|
</el-col>
|
||||||
<el-select
|
</el-row>
|
||||||
v-if="col.select"
|
</el-form>
|
||||||
v-model="dataForm[col.prop]"
|
</div>
|
||||||
clearable
|
<div v-if="dataForm.id && index === 1">
|
||||||
:disabled="detailMode"
|
<el-button v-if="!detailMode" type="primary" style="margin-bottom: 16px" @click="handleAddParam()">添加</el-button>
|
||||||
v-bind="col.elparams"
|
<BaseListTable :table-config="null" :column-config="filteredTableProps" :table-data="subList" @operate-event="handleTableRowOperate" />
|
||||||
@change="handleSelectChange(col, $event)"
|
<!-- paginator -->
|
||||||
>
|
</div>
|
||||||
<el-option
|
</el-tab-pane>
|
||||||
v-for="(opt, optIdx) in col.options"
|
</el-tabs>
|
||||||
:key="'option_' + optIdx"
|
|
||||||
:label="opt.label"
|
|
||||||
:value="opt.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-switch
|
|
||||||
v-if="col.switch"
|
|
||||||
v-model="dataForm[col.prop]"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
@change="handleSwitchChange"
|
|
||||||
:disabled="detailMode"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-if="col.textarea"
|
|
||||||
type="textarea"
|
|
||||||
v-model="dataForm[col.prop]"
|
|
||||||
:disabled="detailMode"
|
|
||||||
v-bind="col.elparams"
|
|
||||||
/>
|
|
||||||
<!-- add more... -->
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
<div v-if="dataForm.id && index === 1">
|
|
||||||
<el-button
|
|
||||||
v-if="!detailMode"
|
|
||||||
type="primary"
|
|
||||||
style="margin-bottom: 16px"
|
|
||||||
@click="handleAddParam()"
|
|
||||||
>添加</el-button
|
|
||||||
>
|
|
||||||
<BaseListTable
|
|
||||||
:table-config="null"
|
|
||||||
:column-config="filteredTableProps"
|
|
||||||
:table-data="subList"
|
|
||||||
@operate-event="handleTableRowOperate"
|
|
||||||
/>
|
|
||||||
<!-- paginator -->
|
|
||||||
</div>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
<!-- sub dialog -->
|
<!-- sub dialog -->
|
||||||
<small-dialog
|
<small-dialog
|
||||||
:append-to-body="true"
|
:append-to-body="true"
|
||||||
v-if="showSubDialog"
|
v-if="showSubDialog"
|
||||||
ref="subDialog"
|
ref="subDialog"
|
||||||
:url="urls.subase"
|
:url="urls.subase"
|
||||||
:configs="configs.subDialog"
|
:configs="configs.subDialog"
|
||||||
:related-id="dataForm.id"
|
:related-id="dataForm.id"
|
||||||
@refreshDataList="getSubList"
|
@refreshDataList="getSubList"
|
||||||
></small-dialog>
|
></small-dialog>
|
||||||
|
|
||||||
<!-- footer -->
|
<!-- footer -->
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<template v-for="(operate, index) in configs.form.operations">
|
<template v-for="(operate, index) in configs.form.operations">
|
||||||
<el-button
|
<el-button v-if="showButton(operate)" :key="'operation_' + index" :type="operate.type" @click="handleBtnClick(operate)">{{
|
||||||
v-if="showButton(operate)"
|
operate.label
|
||||||
:key="'operation_' + index"
|
}}</el-button>
|
||||||
:type="operate.type"
|
</template>
|
||||||
@click="handleBtnClick(operate)"
|
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
|
||||||
>{{ operate.label }}</el-button
|
</div>
|
||||||
>
|
</el-dialog>
|
||||||
</template>
|
|
||||||
<el-button @click="handleBtnClick({ name: 'cancel' })">取消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -133,293 +85,338 @@ import SmallDialog from "@/components/SmallDialog.vue";
|
|||||||
import BaseListTable from "@/components/BaseListTable.vue";
|
import BaseListTable from "@/components/BaseListTable.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "DialogWithMenu",
|
name: "DialogWithMenu",
|
||||||
components: { SmallDialog, BaseListTable },
|
components: { SmallDialog, BaseListTable },
|
||||||
props: {
|
props: {
|
||||||
configs: {
|
configs: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inject: ["urls"],
|
inject: ["urls"],
|
||||||
data() {
|
data() {
|
||||||
const dataForm = {};
|
const dataForm = {};
|
||||||
this.configs.form.rows.forEach((row) => {
|
|
||||||
row.forEach((col) => {
|
|
||||||
dataForm[col.prop] = col.default ?? "";
|
|
||||||
console.log("==========>", col.prop, dataForm[col.prop]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
// configs,
|
|
||||||
activeMenu: this.configs.menu[0].name,
|
|
||||||
dataForm,
|
|
||||||
detailMode: false,
|
|
||||||
selfVisible: false,
|
|
||||||
showBaseDialog: false,
|
|
||||||
baseDialogConfig: null,
|
|
||||||
subList: [],
|
|
||||||
showSubDialog: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
actualMenus() {
|
|
||||||
return this.configs.menu.filter((m) => {
|
|
||||||
if (m.onlyEditMode && !this.dataForm.id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
filteredTableProps() {
|
|
||||||
return this.detailMode
|
|
||||||
? this.configs.table.props.filter((v) => v.prop !== "operations")
|
|
||||||
: this.configs.table.props;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/** utitilities */
|
|
||||||
showButton(operate) {
|
|
||||||
const notDetailMode = !this.detailMode;
|
|
||||||
const showAlways = operate.showAlways ?? false;
|
|
||||||
const editMode = operate.showOnEdit && this.dataForm.id;
|
|
||||||
const addMode = !operate.showOnEdit && !this.dataForm.id;
|
|
||||||
const permission = operate.permission
|
|
||||||
? this.$hasPermission(operate.permission)
|
|
||||||
: true;
|
|
||||||
return (
|
|
||||||
notDetailMode && (showAlways || ((editMode || addMode) && permission))
|
|
||||||
);
|
|
||||||
},
|
|
||||||
resetForm(excludeId = false) {
|
|
||||||
setTimeout(() => {
|
|
||||||
Object.keys(this.dataForm).forEach((key) => {
|
|
||||||
if (excludeId && key === "id") return;
|
|
||||||
this.dataForm[key] = null;
|
|
||||||
});
|
|
||||||
this.activeMenu = this.configs.menu[0].name;
|
|
||||||
}, 500);
|
|
||||||
},
|
|
||||||
|
|
||||||
/** init **/
|
this.configs.form.rows.forEach((row) => {
|
||||||
init(id, detailMode) {
|
row.forEach((col) => {
|
||||||
if (this.$refs.dataForm && this.$refs.dataForm.length) {
|
if (col.upload) dataForm[col.prop] = col.default ?? [];
|
||||||
// 当不是首次渲染dialog的时候,一开始就清空验证信息,本组件的循环里只有一个 dataForm 所以只用取 [0] 即可
|
else dataForm[col.prop] = col.default ?? null;
|
||||||
this.$refs.dataForm[0].clearValidate()
|
|
||||||
}
|
|
||||||
console.log("[dialog] DialogWithHead init():", id, detailMode);
|
|
||||||
|
|
||||||
this.detailMode = detailMode ?? false;
|
if (col.fetchData)
|
||||||
this.$nextTick(() => {
|
col.fetchData().then(({ data: res }) => {
|
||||||
// this.$refs['dataForm'].resetFields();
|
console.log("[Fetch Data]", res.data.list);
|
||||||
|
if (res.code === 0 && res.data.list) {
|
||||||
|
this.$set(
|
||||||
|
col,
|
||||||
|
"options",
|
||||||
|
res.data.list.map((i) => ({ label: i.name, value: i.id }))
|
||||||
|
);
|
||||||
|
// col.options = res.data.list;
|
||||||
|
} else {
|
||||||
|
col.options.splice(0);
|
||||||
|
}
|
||||||
|
// dataForm[col.prop] = col.default ?? null; // not perfect!
|
||||||
|
});
|
||||||
|
else if (col.fetchTreeData) {
|
||||||
|
// 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点
|
||||||
|
col.fetchTreeData().then(({ data: res }) => {
|
||||||
|
console.log("[Fetch Tree Data]", res.data.list);
|
||||||
|
if (res.code === 0 && res.data.list) {
|
||||||
|
// 先把数据先重构成一个对象
|
||||||
|
const obj = {};
|
||||||
|
res.data.list.map((item) => {
|
||||||
|
obj[item.id] = item;
|
||||||
|
});
|
||||||
|
// 再过滤这个对象
|
||||||
|
let filteredList = reConstructTreeData(obj);
|
||||||
|
console.log("** filteredList **", filteredList);
|
||||||
|
// 最后设置 options
|
||||||
|
this.$set(col, "options", filteredList);
|
||||||
|
} else {
|
||||||
|
col.options.splice(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.dataForm.id = id || null;
|
return {
|
||||||
if (this.dataForm.id) {
|
// configs,
|
||||||
// 如果是编辑
|
loadingStatus: false,
|
||||||
this.$http
|
activeMenu: this.configs.menu[0].name,
|
||||||
.get(this.urls.base + `/${this.dataForm.id}`)
|
dataForm,
|
||||||
.then(({ data: res }) => {
|
detailMode: false,
|
||||||
// dev env:
|
selfVisible: false,
|
||||||
// if (LOCAL) res.data.id = res.data._id;
|
showBaseDialog: false,
|
||||||
// end dev env
|
baseDialogConfig: null,
|
||||||
console.log("[base dialog init] ", res);
|
subList: [],
|
||||||
if (res && res.code === 0) {
|
showSubDialog: false,
|
||||||
const dataFormKeys = Object.keys(this.dataForm);
|
};
|
||||||
console.log("keys ===> ", dataFormKeys);
|
},
|
||||||
// console.log('data form keys: ', dataFormKeys, pick(res.data, dataFormKeys))
|
computed: {
|
||||||
this.dataForm = __pick(res.data, dataFormKeys);
|
actualMenus() {
|
||||||
console.log(
|
return this.configs.menu.filter((m) => {
|
||||||
"pick(res.data, dataFormKeys) ===> ",
|
if (m.onlyEditMode && !this.dataForm.id) {
|
||||||
__pick(res.data, dataFormKeys)
|
return false;
|
||||||
);
|
}
|
||||||
// LABEL: FILE_RELATED
|
return true;
|
||||||
/** 对文件下载进行分流 */
|
});
|
||||||
// this.fileList = {};
|
},
|
||||||
// if (this.dataForm.files) {
|
filteredTableProps() {
|
||||||
// // console.log('files: ', this.dataForm.files)
|
return this.detailMode ? this.configs.table.props.filter((v) => v.prop !== "operations") : this.configs.table.props;
|
||||||
// this.dataForm.files.forEach((file) => {
|
},
|
||||||
// // const fileName = file.fileurls.split('/').pop()
|
},
|
||||||
// /** [1] 处理 fileList */
|
methods: {
|
||||||
// // if (Object.hasOwn(this.fileList, file.typeCode)) {
|
/** utitilities */
|
||||||
// if (this.fileList.hasOwnProperty(file.typeCode)) {
|
showButton(operate) {
|
||||||
// /** 已存在 */
|
const notDetailMode = !this.detailMode;
|
||||||
// // this.fileList[file.typeCode].push({ id: file.id, name: fileName, typeCode: file.typeCode })
|
const showAlways = operate.showAlways ?? false;
|
||||||
// this.fileList[file.typeCode].push(file);
|
const editMode = operate.showOnEdit && this.dataForm.id;
|
||||||
// } else {
|
const addMode = !operate.showOnEdit && !this.dataForm.id;
|
||||||
// // this.fileList[file.typeCode] = [{ id: file.id, name: fileName, typeCode: file.typeCode }]
|
const permission = operate.permission ? this.$hasPermission(operate.permission) : true;
|
||||||
// this.fileList[file.typeCode] = [file];
|
return notDetailMode && (showAlways || ((editMode || addMode) && permission));
|
||||||
// }
|
},
|
||||||
|
resetForm(excludeId = false, immediate = false) {
|
||||||
|
setTimeout(
|
||||||
|
() => {
|
||||||
|
Object.keys(this.dataForm).forEach((key) => {
|
||||||
|
if (excludeId && key === "id") return;
|
||||||
|
this.dataForm[key] = null;
|
||||||
|
});
|
||||||
|
this.activeMenu = this.configs.menu[0].name;
|
||||||
|
this.$refs.dataForm[0].clearValidate();
|
||||||
|
this.$emit("dialog-closed"); // 触发父组件销毁自己
|
||||||
|
},
|
||||||
|
immediate ? 0 : 100
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
// /** [2] 处理 fileForm */
|
/** init **/
|
||||||
// // if (Object.hasOwn(this.fileForm, file.typeCode)) {
|
init(id, detailMode) {
|
||||||
// if (this.fileForm.hasOwnProperty(file.typeCode)) {
|
this.selfVisible = true;
|
||||||
// this.fileForm[file.typeCode].push(file.id);
|
if (this.$refs.dataForm && this.$refs.dataForm.length) {
|
||||||
// } else {
|
// 当不是首次渲染dialog的时候,一开始就清空验证信息,本组件的循环里只有一个 dataForm 所以只用取 [0] 即可
|
||||||
// this.fileForm[file.typeCode] = [file.id];
|
this.$refs.dataForm[0].clearValidate();
|
||||||
// }
|
}
|
||||||
// });
|
console.log("[dialog] DialogWithHead init():", id, detailMode);
|
||||||
// }
|
|
||||||
}
|
|
||||||
this.selfVisible = true;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// 如果不是编辑
|
|
||||||
this.selfVisible = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/** handlers */
|
this.detailMode = detailMode ?? false;
|
||||||
handleSelectChange(col, eventValue) {
|
this.$nextTick(() => {
|
||||||
console.log("[dialog] select change: ", col, eventValue);
|
// this.$refs['dataForm'].resetFields();
|
||||||
},
|
|
||||||
handleSwitchChange(val) {
|
|
||||||
console.log("[dialog] switch change: ", val, this.dataForm);
|
|
||||||
},
|
|
||||||
handleBtnClick(payload) {
|
|
||||||
console.log("btn click payload: ", payload);
|
|
||||||
|
|
||||||
if ("name" in payload) {
|
this.dataForm.id = id || null;
|
||||||
switch (payload.name) {
|
if (this.dataForm.id) {
|
||||||
case "cancel":
|
// 如果是编辑
|
||||||
this.handleClose();
|
this.loadingStatus = true;
|
||||||
break;
|
this.$http.get(this.urls.base + `/${this.dataForm.id}`).then(({ data: res }) => {
|
||||||
case "reset":
|
if (res && res.code === 0) {
|
||||||
this.resetForm(true); // true means exclude id
|
const dataFormKeys = Object.keys(this.dataForm);
|
||||||
break;
|
console.log("keys ===> ", dataFormKeys);
|
||||||
case "add":
|
// console.log('data form keys: ', dataFormKeys, pick(res.data, dataFormKeys))
|
||||||
case "update": {
|
this.dataForm = __pick(res.data, dataFormKeys);
|
||||||
const method = payload.name === "add" ? "POST" : "PUT";
|
console.log("pick(res.data, dataFormKeys) ===> ", __pick(res.data, dataFormKeys));
|
||||||
this.$http({
|
// LABEL: FILE_RELATED
|
||||||
url: this.urls.base,
|
/** 对文件下载进行分流 */
|
||||||
method,
|
// this.fileList = {};
|
||||||
data: this.dataForm,
|
// if (this.dataForm.files) {
|
||||||
}).then(({ data: res }) => {
|
// // console.log('files: ', this.dataForm.files)
|
||||||
console.log("[add&update] res is: ", res);
|
// this.dataForm.files.forEach((file) => {
|
||||||
this.$message.success(
|
// // const fileName = file.fileurls.split('/').pop()
|
||||||
payload.name === "add" ? "添加成功" : "更新成功"
|
// /** [1] 处理 fileList */
|
||||||
);
|
// // if (Object.hasOwn(this.fileList, file.typeCode)) {
|
||||||
this.$emit("refreshDataList");
|
// if (this.fileList.hasOwnProperty(file.typeCode)) {
|
||||||
this.handleClose();
|
// /** 已存在 */
|
||||||
});
|
// // this.fileList[file.typeCode].push({ id: file.id, name: fileName, typeCode: file.typeCode })
|
||||||
}
|
// this.fileList[file.typeCode].push(file);
|
||||||
}
|
// } else {
|
||||||
} else {
|
// // this.fileList[file.typeCode] = [{ id: file.id, name: fileName, typeCode: file.typeCode }]
|
||||||
console.log("[x] 不是这么用的! 缺少name属性");
|
// this.fileList[file.typeCode] = [file];
|
||||||
}
|
// }
|
||||||
},
|
|
||||||
handleTabClick(payload) {
|
|
||||||
console.log("tab click payload: ", this.activeMenu);
|
|
||||||
if (this.activeMenu === this.configs.menu[1].name) {
|
|
||||||
// 获取数据
|
|
||||||
this.getSubList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getSubList(page = 1, size = 20) {
|
// /** [2] 处理 fileForm */
|
||||||
const params = {};
|
// // if (Object.hasOwn(this.fileForm, file.typeCode)) {
|
||||||
params.page = page;
|
// if (this.fileForm.hasOwnProperty(file.typeCode)) {
|
||||||
params.limit = size;
|
// this.fileForm[file.typeCode].push(file.id);
|
||||||
|
// } else {
|
||||||
|
// this.fileForm[file.typeCode] = [file.id];
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
this.loadingStatus = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 如果不是编辑
|
||||||
|
this.selfVisible = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
const requiredParams = this.configs.table.extraParams;
|
/** handlers */
|
||||||
if (requiredParams) {
|
handleSelectChange(col, eventValue) {
|
||||||
if (Array.isArray(requiredParams)) {
|
console.log("[dialog] select change: ", col, eventValue);
|
||||||
requiredParams.forEach((str) => {
|
},
|
||||||
if (/id/i.test(str)) {
|
handleSwitchChange(val) {
|
||||||
params[str] = this.dataForm.id;
|
console.log("[dialog] switch change: ", val, this.dataForm);
|
||||||
} else {
|
},
|
||||||
params[str] = "";
|
handleBtnClick(payload) {
|
||||||
}
|
console.log("btn click payload: ", payload);
|
||||||
});
|
|
||||||
} else if (typeof requiredParams === "string") {
|
|
||||||
// 如果需要额外参数,一般肯定需要
|
|
||||||
params[this.configs.table.extraParams] = this.dataForm.id;
|
|
||||||
// 此时 dataForm.id 一定是存在的
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.$http.get(this.urls.subpage, { params }).then(({ data: res }) => {
|
|
||||||
console.log("[subList] getSubList:", res);
|
|
||||||
if (res.code === 0 && res.data?.list) {
|
|
||||||
// 有数据
|
|
||||||
this.subList = res.data.list;
|
|
||||||
} else {
|
|
||||||
this.subList.splice(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleAddParam(id) {
|
if ("name" in payload) {
|
||||||
this.showSubDialog = true;
|
switch (payload.name) {
|
||||||
this.$nextTick(() => {
|
case "cancel":
|
||||||
this.$refs.subDialog.init(id ?? null);
|
this.handleClose();
|
||||||
});
|
break;
|
||||||
},
|
case "reset":
|
||||||
|
this.resetForm(true, true); // true means exclude id
|
||||||
|
break;
|
||||||
|
case "add":
|
||||||
|
case "update": {
|
||||||
|
this.$refs.dataForm[0].validate((passed, result) => {
|
||||||
|
if (passed) {
|
||||||
|
// 如果通过验证
|
||||||
|
this.loadingStatus = true;
|
||||||
|
const method = payload.name === "add" ? "POST" : "PUT";
|
||||||
|
this.$http({
|
||||||
|
url: this.urls.base,
|
||||||
|
method,
|
||||||
|
data: this.dataForm,
|
||||||
|
})
|
||||||
|
.then(({ data: res }) => {
|
||||||
|
console.log("[add&update] res is: ", res);
|
||||||
|
this.$message.success(payload.name === "add" ? "添加成功" : "更新成功");
|
||||||
|
this.$emit("refreshDataList");
|
||||||
|
this.loadingStatus = false;
|
||||||
|
this.handleClose();
|
||||||
|
})
|
||||||
|
.catch((errMsg) => {
|
||||||
|
this.$message.error("参数错误:" + errMsg);
|
||||||
|
if (this.loadingStatus) this.loadingStatus = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 没有通过验证
|
||||||
|
// this.$message.error(JSON.stringify(result));
|
||||||
|
this.$message.error("请核查字段信息");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("[x] 不是这么用的! 缺少name属性");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleTabClick(payload) {
|
||||||
|
console.log("tab click payload: ", this.activeMenu);
|
||||||
|
if (this.activeMenu === this.configs.menu[1].name) {
|
||||||
|
// 获取数据
|
||||||
|
this.getSubList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleClose() {
|
getSubList(page = 1, size = 20) {
|
||||||
this.resetForm();
|
const params = {};
|
||||||
this.selfVisible = false;
|
params.page = page;
|
||||||
},
|
params.limit = size;
|
||||||
|
|
||||||
/** 列表handlers */
|
const requiredParams = this.configs.table.extraParams;
|
||||||
handleAddItem() {
|
if (requiredParams) {
|
||||||
// console.log('[dialog] handleAddItem ot list...');
|
if (Array.isArray(requiredParams)) {
|
||||||
this.showBaseDialog = true;
|
requiredParams.forEach((str) => {
|
||||||
this.$nextTick(() => {
|
if (/id/i.test(str)) {
|
||||||
console.log("[sub-dialog] ", this.$refs["sub-dialog"].init());
|
params[str] = this.dataForm.id;
|
||||||
});
|
} else {
|
||||||
},
|
params[str] = "";
|
||||||
handleTableRowOperate({ type, data }) {
|
}
|
||||||
console.log("handleTableRowOperate", type, data);
|
});
|
||||||
|
} else if (typeof requiredParams === "string") {
|
||||||
|
// 如果需要额外参数,一般肯定需要
|
||||||
|
params[this.configs.table.extraParams] = this.dataForm.id;
|
||||||
|
// 此时 dataForm.id 一定是存在的
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$http.get(this.urls.subpage, { params }).then(({ data: res }) => {
|
||||||
|
console.log("[subList] getSubList:", res);
|
||||||
|
if (res.code === 0 && res.data?.list) {
|
||||||
|
// 有数据
|
||||||
|
this.subList = res.data.list;
|
||||||
|
} else {
|
||||||
|
this.subList.splice(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
switch (type) {
|
handleAddParam(id) {
|
||||||
case "delete": {
|
this.showSubDialog = true;
|
||||||
// 确认是否删除
|
this.$nextTick(() => {
|
||||||
return this.$confirm(`是否删除条目: ${data}`, "提示", {
|
this.$refs.subDialog.init(id ?? null);
|
||||||
confirmButtonText: "确认",
|
});
|
||||||
cancelButtonText: "我再想想",
|
},
|
||||||
type: "warning",
|
|
||||||
})
|
handleClose() {
|
||||||
.then(() => {
|
// this.resetForm();
|
||||||
// this.$http.delete(this.urls.base + `/${data}`).then((res) => {
|
this.selfVisible = false;
|
||||||
this.$http({
|
},
|
||||||
url: this.urls.subase,
|
|
||||||
method: "DELETE",
|
/** 列表handlers */
|
||||||
data: [`${data}`],
|
handleAddItem() {
|
||||||
}).then(({ data: res }) => {
|
// console.log('[dialog] handleAddItem ot list...');
|
||||||
if (res.code === 0) {
|
this.showBaseDialog = true;
|
||||||
this.$message.success({
|
this.$nextTick(() => {
|
||||||
message: "删除成功!",
|
console.log("[sub-dialog] ", this.$refs["sub-dialog"].init());
|
||||||
duration: 1000,
|
});
|
||||||
onClose: () => {
|
},
|
||||||
this.getSubList(1, 20);
|
handleTableRowOperate({ type, data }) {
|
||||||
},
|
console.log("handleTableRowOperate", type, data);
|
||||||
});
|
|
||||||
}
|
switch (type) {
|
||||||
});
|
case "delete": {
|
||||||
})
|
// 确认是否删除
|
||||||
.catch((err) => {});
|
return this.$confirm(`是否删除条目: ${data}`, "提示", {
|
||||||
}
|
confirmButtonText: "确认",
|
||||||
case "edit": {
|
cancelButtonText: "我再想想",
|
||||||
this.handleAddParam(data); /** data is ==> id */
|
type: "warning",
|
||||||
break;
|
})
|
||||||
}
|
.then(() => {
|
||||||
// case 'view-detail-action':
|
// this.$http.delete(this.urls.base + `/${data}`).then((res) => {
|
||||||
// this.openDialog(data, true);
|
this.$http({
|
||||||
// break;
|
url: this.urls.subase,
|
||||||
}
|
method: "DELETE",
|
||||||
},
|
data: [`${data}`],
|
||||||
},
|
}).then(({ data: res }) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$message.success({
|
||||||
|
message: "删除成功!",
|
||||||
|
duration: 1000,
|
||||||
|
onClose: () => {
|
||||||
|
this.getSubList(1, 20);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {});
|
||||||
|
}
|
||||||
|
case "edit": {
|
||||||
|
this.handleAddParam(data); /** data is ==> id */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// case 'view-detail-action':
|
||||||
|
// this.openDialog(data, true);
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.el-menu {
|
.el-menu {
|
||||||
margin: 16px 0 !important;
|
margin: 16px 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-menu.el-menu--horizontal {
|
.el-menu.el-menu--horizontal {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
/* background: #0f02 !important; */
|
/* background: #0f02 !important; */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* .el-menu--horizontal > .el-menu-item.is-active { */
|
/* .el-menu--horizontal > .el-menu-item.is-active { */
|
||||||
@ -427,18 +424,18 @@ export default {
|
|||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
.dialog-with-menu >>> .el-dialog__body {
|
.dialog-with-menu >>> .el-dialog__body {
|
||||||
/* padding-top: 16px !important;
|
/* padding-top: 16px !important;
|
||||||
padding-bottom: 16px !important; */
|
padding-bottom: 16px !important; */
|
||||||
padding-top: 0 !important;
|
padding-top: 0 !important;
|
||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-select {
|
.el-select {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-with-menu >>> .el-dialog__header {
|
.dialog-with-menu >>> .el-dialog__header {
|
||||||
padding: 10px 20px 10px;
|
padding: 10px 20px 10px;
|
||||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white);
|
/* background: linear-gradient(to bottom, rgba(0, 0, 0, 0.25), white); */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
140
src/views/modules/pms/equipment/config.js
Normal file
140
src/views/modules/pms/equipment/config.js
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
import TableOperaionComponent from '@/components/noTemplateComponents/operationComponent'
|
||||||
|
import TableTextComponent from '@/components/noTemplateComponents/detailComponent'
|
||||||
|
import switchBtn from '@/components/noTemplateComponents/switchBtn'
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
|
||||||
|
const tableProps = [
|
||||||
|
{ prop: 'name', label: '设备名称' },
|
||||||
|
{ prop: 'code', label: '设备编码' },
|
||||||
|
{ prop: 'equipmentType', label: '设备类型' },
|
||||||
|
{ prop: 'enabled', label: '状态', subcomponent: switchBtn }, // subcomponent
|
||||||
|
{ prop: 'remark', label: '备注' },
|
||||||
|
{ prop: 'description', label: '查看详情', subcomponent: TableTextComponent },
|
||||||
|
{
|
||||||
|
prop: 'operations',
|
||||||
|
name: '操作',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 120,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: ['edit', { name: 'delete', permission: 'pms:equipment:delete' }]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const headFormFields = [
|
||||||
|
{
|
||||||
|
label: '设备名称',
|
||||||
|
prop: 'name',
|
||||||
|
input: true,
|
||||||
|
default: { value: '' },
|
||||||
|
bind: { placeholder: '请输入设备名称' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
button: {
|
||||||
|
type: 'primary',
|
||||||
|
name: '查询'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
button: {
|
||||||
|
type: 'plain',
|
||||||
|
name: '新增',
|
||||||
|
permission: 'pms:equipment:save'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const dialogConfigs = {
|
||||||
|
menu: [{ name: '设备信息' }, { name: '设备属性信息', onlyEditMode: false }],
|
||||||
|
form: {
|
||||||
|
rows: [
|
||||||
|
[
|
||||||
|
{ input: true, label: '设备名称', prop: 'name', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称' } },
|
||||||
|
{ input: true, label: '设备名称编码', prop: 'code', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称编码' } },
|
||||||
|
// { input: true, label: '版本号', prop: 'version', elparams: { placeholder: '请输入版本号' } },
|
||||||
|
{
|
||||||
|
select: true,
|
||||||
|
label: '设备类型',
|
||||||
|
prop: 'equipmentTypeId',
|
||||||
|
options: [
|
||||||
|
// { label: '1', value: 1 },
|
||||||
|
// { label: '2', value: 2 },
|
||||||
|
// { label: '3', value: 3 },
|
||||||
|
],
|
||||||
|
fetchData: () => {
|
||||||
|
return this.$http.get('/pms/equipmentType/page', { params: { page: 1, limit: 999, key: '' } })
|
||||||
|
},
|
||||||
|
elparams: { placeholder: '选择一个设备类型' }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[{ textarea: true, label: '备注', prop: 'remark', elparams: { placeholder: '备注' } }],
|
||||||
|
],
|
||||||
|
operations: [
|
||||||
|
{ name: 'add', label: '保存', type: 'primary', permission: 'pms:equipment:save', showOnEdit: false },
|
||||||
|
{ name: 'update', label: '更新', type: 'primary', permission: 'pms:equipment:update', showOnEdit: true },
|
||||||
|
{ name: 'reset', label: '重置', type: 'warning', showAlways: true },
|
||||||
|
// { name: 'cancel', label: '取消', showAlways: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
table: {
|
||||||
|
// extraParams: ['stepId'],
|
||||||
|
extraParams: 'stepId',
|
||||||
|
props: [
|
||||||
|
{ prop: 'createTime', label: '创建时间' },
|
||||||
|
{ prop: 'equipmentId', label: '所属设备id' },
|
||||||
|
{ prop: 'attrName', label: '属性名称', isEditField: true },
|
||||||
|
{ prop: 'attrValue', label: '属性值', isEditField: true },
|
||||||
|
{
|
||||||
|
prop: 'operations',
|
||||||
|
name: '操作',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 120,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: [
|
||||||
|
{ name: 'edit', permission: 'pms:equipment:update' },
|
||||||
|
{ name: 'delete', permission: 'pms:equipment:delete' },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
data: [
|
||||||
|
// TOOD 暂时用不到,但获取可以考虑把拉取接口数据的函数迁移到此文件(没有太大必要)
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
subDialog: {
|
||||||
|
extraParam: 'equipmentId',
|
||||||
|
rows: [
|
||||||
|
[
|
||||||
|
{ input: true, label: '属性名称', prop: 'attrName', elparams: { placeholder: '请输入属性名称' } },
|
||||||
|
{ input: true, label: '属性值', prop: 'attrValue', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入属性值' } },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ textarea: true, label: '备注', prop: 'remark', elparams: { placeholder: '添加备注' } },
|
||||||
|
]
|
||||||
|
],
|
||||||
|
operations: [
|
||||||
|
{ name: 'add', label: '保存', type: 'primary', permission: 'pms:equipment:save', showOnEdit: false },
|
||||||
|
{ name: 'update', label: '更新', type: 'primary', permission: 'pms:equipment:update', showOnEdit: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
dialogConfigs,
|
||||||
|
tableConfig: {
|
||||||
|
table: null, // 此处可省略,el-table 上的配置项
|
||||||
|
column: tableProps, // el-column-item 上的配置项
|
||||||
|
},
|
||||||
|
headFormConfigs: {
|
||||||
|
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
fields: headFormFields // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
},
|
||||||
|
urls: {
|
||||||
|
base: '/pms/equipment',
|
||||||
|
page: '/pms/equipment/page'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
src/views/modules/pms/equipment/index.vue
Normal file
32
src/views/modules/pms/equipment/index.vue
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<ListViewWithHead :table-config="tableConfig" :head-config="headFormConfigs" :dialog-configs="dialogConfigs" :listQueryExtra="['name']" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import initConfig from './config';
|
||||||
|
import ListViewWithHead from '@/views/atomViews/ListViewWithHead.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BlenderView',
|
||||||
|
components: { ListViewWithHead },
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
urls: this.allUrls
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
|
||||||
|
return {
|
||||||
|
tableConfig,
|
||||||
|
headFormConfigs,
|
||||||
|
allUrls: urls,
|
||||||
|
dialogConfigs,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {},
|
||||||
|
mounted() {},
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
149
src/views/modules/pms/product/config.js
Normal file
149
src/views/modules/pms/product/config.js
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
import TableOperaionComponent from '@/components/noTemplateComponents/operationComponent'
|
||||||
|
import TableTextComponent from '@/components/noTemplateComponents/detailComponent'
|
||||||
|
import StatusComponent from '@/components/noTemplateComponents/statusComponent'
|
||||||
|
import { timeFilter, dictFilter } from '@/utils/filters'
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
|
||||||
|
const tableProps = [
|
||||||
|
{ prop: 'createTime', label: '添加时间', filter: timeFilter },
|
||||||
|
{ prop: 'name', label: '产品名称' },
|
||||||
|
{ prop: 'code', label: '产品编码' },
|
||||||
|
{ prop: 'typeDictValue', label: '产品类型', filter: dictFilter('product_type') },
|
||||||
|
{ prop: 'specifications', label: '规格' },
|
||||||
|
{ prop: 'unitDictValue', label: '单位', filter: dictFilter('unit') },
|
||||||
|
{ prop: 'weight', label: '重量(kg)' },
|
||||||
|
{ prop: 'remark', label: '备注' },
|
||||||
|
{ prop: 'description', label: '附件信息', subcomponent: TableTextComponent, buttonContent: '查看附件' },
|
||||||
|
{
|
||||||
|
prop: 'operations',
|
||||||
|
name: '操作',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 120,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: ['edit', { name: 'delete', permission: 'pms:product:delete' }]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const headFormFields = [
|
||||||
|
{
|
||||||
|
label: '关键字',
|
||||||
|
prop: 'key',
|
||||||
|
input: true,
|
||||||
|
default: { value: '' },
|
||||||
|
bind: { placeholder: '请输入产品名称或编码' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
button: {
|
||||||
|
type: 'primary',
|
||||||
|
name: '查询'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
button: {
|
||||||
|
type: 'plain',
|
||||||
|
name: '新增',
|
||||||
|
permission: 'pms:product:save'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const dictList = JSON.parse(localStorage.getItem('dictList') || {})
|
||||||
|
const dialogConfigs = {
|
||||||
|
menu: [{ name: '产品信息' }, { name: '产品属性信息', onlyEditMode: false }],
|
||||||
|
form: {
|
||||||
|
rows: [
|
||||||
|
[
|
||||||
|
{ input: true, label: '产品名称/砖型名称', prop: 'name', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称' } },
|
||||||
|
{ input: true, label: '产品编码/砖型编码', prop: 'code', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称编码' } },
|
||||||
|
// { input: true, label: '版本号', prop: 'version', elparams: { placeholder: '请输入版本号' } },
|
||||||
|
{
|
||||||
|
select: true,
|
||||||
|
label: '产品类型',
|
||||||
|
prop: 'typeDictValue',
|
||||||
|
options: 'product_type' in dictList ? dictList['product_type'].map(item => ({ value: item.dictValue, label: item.dictLabel })) : [],
|
||||||
|
elparams: { placeholder: '选择一个产品类型' }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ input: true, label: '规格', prop: 'specifications', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称编码' } },
|
||||||
|
{ input: true, label: '单位平方数', prop: 'code', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入设备名称编码' } },
|
||||||
|
{
|
||||||
|
select: true,
|
||||||
|
label: '单位',
|
||||||
|
prop: 'unitDictValue',
|
||||||
|
options: 'unit' in dictList ? dictList['unit'].map(item => ({ value: item.dictValue, label: item.dictLabel })) : [],
|
||||||
|
elparams: { placeholder: '选择一个产品类型' }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[{ textarea: true, label: '备注', prop: 'remark', elparams: { placeholder: '备注' } }],
|
||||||
|
],
|
||||||
|
operations: [
|
||||||
|
{ name: 'add', label: '保存', type: 'primary', permission: 'pms:product:save', showOnEdit: false },
|
||||||
|
{ name: 'update', label: '更新', type: 'primary', permission: 'pms:product:update', showOnEdit: true },
|
||||||
|
{ name: 'reset', label: '重置', type: 'warning', showAlways: true },
|
||||||
|
// { name: 'cancel', label: '取消', showAlways: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
table: {
|
||||||
|
// extraParams: ['stepId'],
|
||||||
|
extraParams: 'productId',
|
||||||
|
props: [
|
||||||
|
{ prop: 'createTime', label: '创建时间' },
|
||||||
|
{ prop: 'productId', label: '产品ID' },
|
||||||
|
{ prop: 'attrName', label: '属性名称', isEditField: true },
|
||||||
|
{ prop: 'attrValue', label: '属性值', isEditField: true },
|
||||||
|
{
|
||||||
|
prop: 'operations',
|
||||||
|
name: '操作',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 120,
|
||||||
|
subcomponent: TableOperaionComponent,
|
||||||
|
options: [
|
||||||
|
{ name: 'edit', permission: 'pms:product:update' },
|
||||||
|
{ name: 'delete', permission: 'pms:product:delete' },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
data: [
|
||||||
|
// TOOD 暂时用不到,但获取可以考虑把拉取接口数据的函数迁移到此文件(没有太大必要)
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
subDialog: {
|
||||||
|
extraParam: 'productId',
|
||||||
|
rows: [
|
||||||
|
[
|
||||||
|
{ input: true, label: '属性名称', prop: 'attrName', elparams: { placeholder: '请输入属性名称' } },
|
||||||
|
{ input: true, label: '属性值', prop: 'attrValue', rules: { required: true, message: 'not empty', trigger: 'blur' }, elparams: { placeholder: '请输入属性值' } },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ textarea: true, label: '备注', prop: 'remark', elparams: { placeholder: '添加备注' } },
|
||||||
|
]
|
||||||
|
],
|
||||||
|
operations: [
|
||||||
|
{ name: 'add', label: '保存', type: 'primary', permission: 'pms:product:save', showOnEdit: false },
|
||||||
|
{ name: 'update', label: '更新', type: 'primary', permission: 'pms:product:update', showOnEdit: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
dialogConfigs,
|
||||||
|
tableConfig: {
|
||||||
|
table: null, // 此处可省略,el-table 上的配置项
|
||||||
|
column: tableProps, // el-column-item 上的配置项
|
||||||
|
},
|
||||||
|
headFormConfigs: {
|
||||||
|
rules: null, // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
fields: headFormFields // 名称是由 BaseSearchForm.vue 组件固定的
|
||||||
|
},
|
||||||
|
urls: {
|
||||||
|
base: '/pms/product',
|
||||||
|
page: '/pms/product/page'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
src/views/modules/pms/product/index.vue
Normal file
32
src/views/modules/pms/product/index.vue
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<ListViewWithHead :table-config="tableConfig" :head-config="headFormConfigs" :dialog-configs="dialogConfigs" :listQueryExtra="['key']" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import initConfig from './config';
|
||||||
|
import ListViewWithHead from '@/views/atomViews/ListViewWithHead.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BlenderView',
|
||||||
|
components: { ListViewWithHead },
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
urls: this.allUrls
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
const { tableConfig, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
|
||||||
|
return {
|
||||||
|
tableConfig,
|
||||||
|
headFormConfigs,
|
||||||
|
allUrls: urls,
|
||||||
|
dialogConfigs,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {},
|
||||||
|
mounted() {},
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
Loading…
Reference in New Issue
Block a user