add SwitchBtn 组件

This commit is contained in:
lb 2023-01-31 10:35:26 +08:00
parent 7c8f844ace
commit e6fe05ae17
5 ha cambiato i file con 78 aggiunte e 8 eliminazioni

Vedi File

@ -39,7 +39,7 @@
<script>
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.103:8080/pms-am';
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.49:8080/pms-am'; // tengyun
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.62:8080/pms-am'; // tengyun
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.62:8080/pms-am'; // tao
</script>
<% } %>
<!-- 集成测试环境 -->

Vedi File

@ -1,2 +1,55 @@
// 表格中的开关
export default {}
// 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)
}
}
}
);
},
};

Vedi File

@ -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 || '-'
}
}

Vedi File

@ -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;
}
}
},

Vedi File

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