ソースを参照

update switchBtn

docs_0727
lb 1年前
コミット
6b292d9a47
5個のファイルの変更46行の追加23行の削除
  1. +7
    -4
      src/components/noTemplateComponents/switchBtn.js
  2. +10
    -12
      src/views/atomViews/ListViewWithHead.vue
  3. +25
    -4
      src/views/modules/pms/material/components/ListViewWithHead.vue
  4. +1
    -1
      src/views/modules/pms/material/config.js
  5. +3
    -2
      src/views/modules/pms/productionLine/config.js

+ 7
- 4
src/components/noTemplateComponents/switchBtn.js ファイルの表示

@@ -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,11 +35,11 @@ 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) {
var self = this
var self = this
return h( return h(
"el-switch", "el-switch",
{ {


+ 10
- 12
src/views/atomViews/ListViewWithHead.vue ファイルの表示

@@ -222,20 +222,18 @@ 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
.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; break;
} }
} }


+ 25
- 4
src/views/modules/pms/material/components/ListViewWithHead.vue ファイルの表示

@@ -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) => ({
...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.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;
}
} }
}, },




+ 1
- 1
src/views/modules/pms/material/config.js ファイルの表示

@@ -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: [


+ 3
- 2
src/views/modules/pms/productionLine/config.js ファイルの表示

@@ -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: "备注" },


読み込み中…
キャンセル
保存