update switchBtn
This commit is contained in:
parent
151f787f0a
commit
6b292d9a47
@ -10,9 +10,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const elSwitchModel = this.injectData.enabled ? true : false
|
const propName = this.injectData.head.prop
|
||||||
|
let elSwitchModel = this.injectData[propName] ? true : false
|
||||||
|
|
||||||
return {
|
return {
|
||||||
elSwitchModel
|
elSwitchModel,
|
||||||
|
propName
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -32,7 +35,7 @@ export default {
|
|||||||
// 发射事件
|
// 发射事件
|
||||||
emit(booleanValue) {
|
emit(booleanValue) {
|
||||||
const { id, code } = this.injectData
|
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) {
|
render: function (h) {
|
||||||
|
@ -222,16 +222,14 @@ export default {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "status": {
|
case "status": {
|
||||||
|
console.log('status', data)
|
||||||
// TODO: 类似于这种字符串,可以统一集中到一个文件里
|
// 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
|
// 更改状态,更改状态需要 id 和 code 然后是 状态 enabled
|
||||||
this.$http
|
this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => {
|
||||||
.put(this.urls.base, {
|
|
||||||
id,
|
|
||||||
code,
|
|
||||||
enabled,
|
|
||||||
})
|
|
||||||
.then(({ data: res }) => {
|
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,10 @@ import DialogJustForm from "@/components/DialogJustForm.vue";
|
|||||||
const DIALOG_WITH_MENU = "DialogWithMenu";
|
const DIALOG_WITH_MENU = "DialogWithMenu";
|
||||||
const DIALOG_JUST_FORM = "DialogJustForm";
|
const DIALOG_JUST_FORM = "DialogJustForm";
|
||||||
|
|
||||||
|
function constructToTree(list) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ListViewWithHead",
|
name: "ListViewWithHead",
|
||||||
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm },
|
components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm },
|
||||||
@ -146,10 +150,12 @@ export default {
|
|||||||
// page 场景:
|
// page 场景:
|
||||||
if ("list" in res.data) {
|
if ("list" in res.data) {
|
||||||
// real env:
|
// real env:
|
||||||
this.dataList = res.data.list.map((item) => ({
|
this.dataList = constructToTree(
|
||||||
|
res.data.list.map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
id: item._id ?? item.id,
|
id: item._id ?? item.id,
|
||||||
}));
|
}))
|
||||||
|
);
|
||||||
// this.dataList = res.data.records;
|
// this.dataList = res.data.records;
|
||||||
this.totalPage = res.data.total;
|
this.totalPage = res.data.total;
|
||||||
} else if ("records" in res.data) {
|
} else if ("records" in res.data) {
|
||||||
@ -214,6 +220,21 @@ export default {
|
|||||||
this.openDialog(data, true);
|
this.openDialog(data, true);
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export default function () {
|
|||||||
menu: [
|
menu: [
|
||||||
{ name: "物料信息", key: "info" },
|
{ name: "物料信息", key: "info" },
|
||||||
{ name: "物料属性信息", key: "attr", onlyEditMode: true },
|
{ name: "物料属性信息", key: "attr", onlyEditMode: true },
|
||||||
{ name: "子类", key: "add-sub", onlyEditMode: true },
|
{ name: "添加子类", key: "add-sub", onlyEditMode: true },
|
||||||
],
|
],
|
||||||
form: {
|
form: {
|
||||||
rows: [
|
rows: [
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
|
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
|
||||||
import StatusComponent from "@/components/noTemplateComponents/statusComponent";
|
import switchBtn from "@/components/noTemplateComponents/switchBtn";
|
||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
@ -7,7 +7,8 @@ export default function () {
|
|||||||
{ prop: "name", label: "产线名称" },
|
{ prop: "name", label: "产线名称" },
|
||||||
{ prop: "code", label: "产线编码" },
|
{ prop: "code", label: "产线编码" },
|
||||||
{ prop: "factory", label: "所属工厂" },
|
{ prop: "factory", label: "所属工厂" },
|
||||||
{ prop: "status", label: "产线状态", subcomponent: StatusComponent }, // subcomponent
|
{ prop: "status", label: "产线状态", subcomponent: switchBtn }, // subcomponent
|
||||||
|
// TODO: 2023.2.3 产线状态切换功能不生效
|
||||||
{ prop: "tvalue", label: "每小时下片数量" },
|
{ prop: "tvalue", label: "每小时下片数量" },
|
||||||
{ prop: "description", label: "描述" },
|
{ prop: "description", label: "描述" },
|
||||||
{ prop: "remark", label: "备注" },
|
{ prop: "remark", label: "备注" },
|
||||||
|
Loading…
Reference in New Issue
Block a user