update switchBtn

This commit is contained in:
lb 2023-02-03 17:14:12 +08:00
bovenliggende 151f787f0a
commit 6b292d9a47
5 gewijzigde bestanden met toevoegingen van 46 en 23 verwijderingen

Bestand weergeven

@ -10,9 +10,12 @@ export default {
},
},
data() {
const elSwitchModel = this.injectData.enabled ? true : false
const propName = this.injectData.head.prop
let elSwitchModel = this.injectData[propName] ? true : false
return {
elSwitchModel
elSwitchModel,
propName
};
},
mounted() {
@ -32,11 +35,11 @@ export default {
// 发射事件
emit(booleanValue) {
const { id, code } = this.injectData
this.$emit('emit-data', { type: 'status', data: { id, code, enabled: booleanValue ? '1' : '0' } })
this.$emit('emit-data', { type: 'status', data: { id, code, [this.propName]: booleanValue ? '1' : '0' } })
},
},
render: function (h) {
var self = this
var self = this
return h(
"el-switch",
{

Bestand weergeven

@ -222,20 +222,18 @@ export default {
break;
}
case "status": {
console.log('status', data)
// TODO:
const { id, code, enabled } = data;
const { id, code } = data;
const queryCondition = { id, code };
if ("enabled" in data) queryCondition.enabled = data['enabled'];
if ("status" in data) queryCondition.status = data['status'];
// id code enabled
this.$http
.put(this.urls.base, {
id,
code,
enabled,
})
.then(({ data: res }) => {
if (res.code === 0) {
// do nothing
}
});
this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => {
if (res.code === 0) {
// do nothing
}
});
break;
}
}

Bestand weergeven

@ -56,6 +56,10 @@ import DialogJustForm from "@/components/DialogJustForm.vue";
const DIALOG_WITH_MENU = "DialogWithMenu";
const DIALOG_JUST_FORM = "DialogJustForm";
function constructToTree(list) {
return list;
}
export default {
name: "ListViewWithHead",
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm },
@ -146,10 +150,12 @@ export default {
// page :
if ("list" in res.data) {
// real env:
this.dataList = res.data.list.map((item) => ({
...item,
id: item._id ?? item.id,
}));
this.dataList = constructToTree(
res.data.list.map((item) => ({
...item,
id: item._id ?? item.id,
}))
);
// this.dataList = res.data.records;
this.totalPage = res.data.total;
} else if ("records" in res.data) {
@ -214,6 +220,21 @@ export default {
this.openDialog(data, true);
break;
}
case "status": {
console.log('status', data)
// TODO:
const { id, code } = data;
const queryCondition = { id, code };
if ("enabled" in data) queryCondition.enabled = data['enabled'];
if ("status" in data) queryCondition.status = data['status'];
// id code enabled
this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => {
if (res.code === 0) {
// do nothing
}
});
break;
}
}
},

Bestand weergeven

@ -61,7 +61,7 @@ export default function () {
menu: [
{ name: "物料信息", key: "info" },
{ name: "物料属性信息", key: "attr", onlyEditMode: true },
{ name: "子类", key: "add-sub", onlyEditMode: true },
{ name: "添加子类", key: "add-sub", onlyEditMode: true },
],
form: {
rows: [

Bestand weergeven

@ -1,5 +1,5 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
import StatusComponent from "@/components/noTemplateComponents/statusComponent";
import switchBtn from "@/components/noTemplateComponents/switchBtn";
import request from "@/utils/request";
export default function () {
@ -7,7 +7,8 @@ export default function () {
{ prop: "name", label: "产线名称" },
{ prop: "code", label: "产线编码" },
{ prop: "factory", label: "所属工厂" },
{ prop: "status", label: "产线状态", subcomponent: StatusComponent }, // subcomponent
{ prop: "status", label: "产线状态", subcomponent: switchBtn }, // subcomponent
// TODO: 2023.2.3 产线状态切换功能不生效
{ prop: "tvalue", label: "每小时下片数量" },
{ prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },