diff --git a/public/index.html b/public/index.html
index fadabb2..d204e3c 100644
--- a/public/index.html
+++ b/public/index.html
@@ -39,7 +39,7 @@
<% } %>
diff --git a/src/components/noTemplateComponents/switchBtn.js b/src/components/noTemplateComponents/switchBtn.js
index 30587a4..5ac0f3c 100644
--- a/src/components/noTemplateComponents/switchBtn.js
+++ b/src/components/noTemplateComponents/switchBtn.js
@@ -1,2 +1,55 @@
// 表格中的开关
-export default {}
\ No newline at end of file
+// import i18n from '@/i18n'
+
+export default {
+ name: "SwitchBtn",
+ props: {
+ injectData: {
+ type: Object,
+ default: () => ({}),
+ },
+ },
+ data() {
+ const elSwitchModel = this.injectData.enabled ? true : false
+ return {
+ elSwitchModel
+ };
+ },
+ mounted() {
+ // console.log("[SwitchBtn] injectData: ", this.injectData);
+ },
+ computed: {
+ status: {
+ get() {
+ return this.elSwitchModel
+ },
+ set(val) {
+ this.elSwitchModel = val
+ }
+ }
+ },
+ methods: {
+ // 发射事件
+ emit(booleanValue) {
+ const { id, code } = this.injectData
+ this.$emit('emit-data', { type: 'status', data: { id, code, enabled: booleanValue ? '1' : '0' } })
+ },
+ },
+ render: function (h) {
+ var self = this
+ return h(
+ "el-switch",
+ {
+ props: {
+ value: self.status,
+ },
+ on: {
+ change: function (val) {
+ self.status = val
+ self.emit(val)
+ }
+ }
+ }
+ );
+ },
+};
diff --git a/src/utils/filters.js b/src/utils/filters.js
index 9d8539b..e7f1c28 100644
--- a/src/utils/filters.js
+++ b/src/utils/filters.js
@@ -3,7 +3,6 @@ import moment from 'moment'
export const dictFilter = dictTypeId => {
return val => {
- console.log('ddd', (JSON.parse(localStorage.getItem('dictList')))[dictTypeId])
return JSON.parse(localStorage.getItem('dictList'))[dictTypeId].find(item => item.dictValue === val)?.dictLabel || '-'
}
}
diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue
index 3ae5acc..a9bb19b 100644
--- a/src/views/atomViews/ListViewWithHead.vue
+++ b/src/views/atomViews/ListViewWithHead.vue
@@ -197,6 +197,23 @@ export default {
this.openDialog(data, true);
break;
}
+ case "status": {
+ // TODO: 类似于这种字符串,可以统一集中到一个文件里
+ const { id, code, enabled } = data;
+ // 更改状态,更改状态需要 id 和 code 然后是 状态 enabled
+ this.$http
+ .put(this.urls.base, {
+ id,
+ code,
+ enabled,
+ })
+ .then(({ data: res }) => {
+ if (res.code === 0) {
+ // do nothing
+ }
+ });
+ break;
+ }
}
},
diff --git a/src/views/modules/pms/materialStorage/config.js b/src/views/modules/pms/materialStorage/config.js
index 09a99a9..f2961b1 100644
--- a/src/views/modules/pms/materialStorage/config.js
+++ b/src/views/modules/pms/materialStorage/config.js
@@ -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";
import { dictFilter } from '@/utils/filters'
@@ -7,8 +7,8 @@ export default function () {
const tableProps = [
{ prop: "name", label: "料仓名称" },
{ prop: "code", label: "料仓编码" },
- { prop: "typeDictValue", label: "料仓类型", filter: dictFilter('liangcang') },
- { prop: "status", label: "产线状态", subcomponent: StatusComponent }, // subcomponent
+ { prop: "typeDictValue", label: "料仓类型", filter: dictFilter('liaocang') },
+ { prop: "status", label: "状态", subcomponent: switchBtn }, // subcomponent
{ prop: "description", label: "描述" },
{ prop: "remark", label: "备注" },
{
@@ -78,8 +78,9 @@ export default function () {
prop: "typeDictValue",
// fetchData: () => this.$http.get("/pms/factory/page", { params: { limit: 999, page: 1 } }),
options: [
- { label: '中间仓', value: 0 },
- { label: '日料仓', value: 1 },
+ // TODO: 或许映射可以全权交给数据字典
+ { label: '中间仓', value: '0' },
+ { label: '日料仓', value: '1' },
],
rules: { required: true, message: "not empty", trigger: "change" },
},