init
This commit is contained in:
144
src/views/EquipmentManager/BOMManager/AddForm.vue
Normal file
144
src/views/EquipmentManager/BOMManager/AddForm.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<!--
|
||||
* @Date: 2021-01-12 09:37:27
|
||||
* @LastEditors: guo
|
||||
* @LastEditTime: 2021-03-22 15:31:49
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\AddForm.vue
|
||||
* @Description: 物料BOM添加弹窗页面
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-bind="$attrs" :title="$t('module.equipmentManager.bom.addDialogTitle')" v-on="$listeners" @open="onOpen" @close="onClose">
|
||||
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="220px">
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.equipmentName')" prop="equipmentId">
|
||||
<el-select v-model="formData.equipmentId" :placeholder="$t('module.equipmentManager.bom.placeholderequipmentName')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.device"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.name')" prop="code">
|
||||
<el-select v-model="formData.code" :placeholder="$t('module.equipmentManager.bom.placeholdername')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.bom"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.enabled')" prop="enabled" required>
|
||||
<el-switch v-model="formData.enabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.remark')" prop="remark">
|
||||
<el-input v-model="formData.remark" :placeholder="$t('module.equipmentManager.bom.placeholderremark')" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
<!-- :loading="waiting" -->
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { addBOM } from '@/api/equipment/bom'
|
||||
import { getDictDevice, getDictBom } from '@/api/dict'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: [],
|
||||
data() {
|
||||
return {
|
||||
waiting: false,
|
||||
formData: {
|
||||
equipmentId: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
enabled: 1,
|
||||
remark: undefined
|
||||
},
|
||||
rules: {
|
||||
equipmentId: [{
|
||||
required: true,
|
||||
message: '请选择设备名称',
|
||||
trigger: 'change'
|
||||
}],
|
||||
code: [{
|
||||
required: true,
|
||||
message: '请选择物料',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
name: [{
|
||||
required: true,
|
||||
message: '请输入物料BOM名称',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
remark: []
|
||||
},
|
||||
dict: {
|
||||
device: [],
|
||||
bom: []
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {},
|
||||
mounted() {
|
||||
this.getDict()
|
||||
},
|
||||
methods: {
|
||||
onOpen() {},
|
||||
onClose() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
// this.waiting = true
|
||||
this.$refs['elForm'].validate(async valid => {
|
||||
if (!valid) {
|
||||
// this.waiting = false
|
||||
return
|
||||
}
|
||||
this.dict.bom.map(item => {
|
||||
if (item.code === this.formData.code) {
|
||||
this.formData.name = item.name
|
||||
}
|
||||
})
|
||||
const result = await addBOM(this.formData)
|
||||
// this.waiting = false
|
||||
console.log(1)
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
})
|
||||
this.$emit('done')
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getDict() {
|
||||
const result = await getDictDevice({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.dict.device = result
|
||||
const res = await getDictBom({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.dict.bom = res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
155
src/views/EquipmentManager/BOMManager/EditForm.vue
Normal file
155
src/views/EquipmentManager/BOMManager/EditForm.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<!--
|
||||
* @Date: 2021-01-12 09:37:27
|
||||
* @LastEditors: guo
|
||||
* @LastEditTime: 2021-03-22 15:32:19
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\EditForm.vue
|
||||
* @Description: 物料BOM编辑弹窗页面
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-bind="$attrs" :title="$t('module.equipmentManager.bom.editDialogTitle')" v-on="$listeners" @open="onOpen" @close="onClose">
|
||||
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="220px">
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.equipmentName')" prop="equipmentId">
|
||||
<el-select v-model="formData.equipmentId" :placeholder="$t('module.equipmentManager.bom.placeholderequipmentName')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.device"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.name')" prop="code">
|
||||
<el-select v-model="formData.code" :placeholder="$t('module.equipmentManager.bom.placeholdername')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.bom"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.enabled')" prop="enabled" required>
|
||||
<el-switch v-model="formData.enabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.remark')" prop="remark">
|
||||
<el-input v-model="formData.remark" :placeholder="$t('module.equipmentManager.bom.placeholderremark')" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getBOMInfo, editBOM } from '@/api/equipment/bom'
|
||||
import { getDictDevice, getDictBom } from '@/api/dict'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
targetInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
equipmentId: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
enabled: 1,
|
||||
remark: undefined
|
||||
},
|
||||
rules: {
|
||||
equipmentId: [{
|
||||
required: true,
|
||||
message: '请选择设备名称',
|
||||
trigger: 'change'
|
||||
}],
|
||||
code: [{
|
||||
required: false,
|
||||
message: '请输入物料BOM编码',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
name: [{
|
||||
required: true,
|
||||
message: '请输入物料BOM名称',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
remark: []
|
||||
},
|
||||
dict: {
|
||||
device: [],
|
||||
bom: []
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {},
|
||||
mounted() {
|
||||
this.getDict()
|
||||
},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.getDetail()
|
||||
},
|
||||
onClose() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
this.$refs['elForm'].validate(async valid => {
|
||||
if (!valid) return
|
||||
this.dict.bom.map(item => {
|
||||
if (item.code === this.formData.code) {
|
||||
this.formData.name = item.name
|
||||
}
|
||||
})
|
||||
const result = await editBOM({
|
||||
...this.formData,
|
||||
id: this.targetInfo?.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
})
|
||||
this.$emit('done')
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getDetail() {
|
||||
const result = await getBOMInfo({
|
||||
id: this.targetInfo?.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.formData = result.data
|
||||
// console.log(result)
|
||||
}
|
||||
},
|
||||
async getDict() {
|
||||
const result = await getDictDevice({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.dict.device = result
|
||||
const res = await getDictBom({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.dict.bom = res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
172
src/views/EquipmentManager/BOMManager/index.vue
Normal file
172
src/views/EquipmentManager/BOMManager/index.vue
Normal file
@@ -0,0 +1,172 @@
|
||||
<!--
|
||||
* @Date: 2020-12-15 15:36:52
|
||||
* @LastEditors: gtz
|
||||
* @LastEditTime: 2021-04-21 14:00:18
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\index.vue
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<div class="usermanager-container">
|
||||
<div class="method-btn-area">
|
||||
<el-input v-model="listQuery.keywords" :placeholder="$t('module.equipmentManager.bom.searchPlaceholder')" style="width: 200px;" clearable />
|
||||
<el-button @click="getList">{{ 'btn.search' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="showDialog = true">{{ 'btn.add' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
<base-table :table-config="tableProps" :table-data="list" :is-loading="listLoading" :page="listQuery.current" :limit="listQuery.size">
|
||||
<method-btn slot="handleBtn" :method-list="tableBtn" @clickBtn="handleClick" />
|
||||
</base-table>
|
||||
<pagination :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size" @pagination="getList" />
|
||||
<add-form :visible.sync="showDialog" @done="getList" />
|
||||
<edit-form :visible.sync="showEditDialog" :target-info="{id: curEditId}" @done="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import dataDict from '@/filters/DataDict'
|
||||
// edit here
|
||||
const tableBtn = [{
|
||||
type: 'edit',
|
||||
btnName: 'btn.edit'
|
||||
}, {
|
||||
type: 'delete',
|
||||
btnName: 'btn.delete'
|
||||
}, {
|
||||
type: 'detail',
|
||||
btnName: 'btn.detail'
|
||||
}]
|
||||
const tableProps = [{
|
||||
prop: 'code',
|
||||
label: i18n.t('module.equipmentManager.bom.code'),
|
||||
align: 'center',
|
||||
sortable: true,
|
||||
sortMethod: (a, b) => {
|
||||
// 返回-1, 1或者0
|
||||
}
|
||||
}, {
|
||||
prop: 'name',
|
||||
label: i18n.t('module.equipmentManager.bom.name'),
|
||||
align: 'center',
|
||||
sortable: true
|
||||
}, {
|
||||
prop: 'equipmentCode',
|
||||
label: i18n.t('module.equipmentManager.bom.equipmentCode'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'equipmentName',
|
||||
label: i18n.t('module.equipmentManager.bom.equipmentName'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'enabled',
|
||||
label: i18n.t('module.equipmentManager.bom.enabled'),
|
||||
align: 'center',
|
||||
filter: dataDict('enableState')
|
||||
}, {
|
||||
prop: 'remark',
|
||||
label: i18n.t('module.equipmentManager.bom.remark'),
|
||||
align: 'center'
|
||||
}]
|
||||
import AddForm from './AddForm'
|
||||
import EditForm from './EditForm'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
// edit here
|
||||
import { getBOMList, delBOM } from '@/api/equipment/bom'
|
||||
// , getMaterialList
|
||||
import { objFilter } from '@/utils'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
name: 'OrgManager',
|
||||
components: { Pagination, BaseTable, MethodBtn, AddForm, EditForm },
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
tableBtn,
|
||||
tableProps,
|
||||
list: [],
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
showDialog: false,
|
||||
curEditId: null,
|
||||
showEditDialog: false,
|
||||
listQuery: {
|
||||
current: 1,
|
||||
size: 10,
|
||||
keywords: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
// this.listLoading = false
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
handleClick(raw) {
|
||||
console.log(raw)
|
||||
switch (raw.type) {
|
||||
case 'delete':
|
||||
this.$confirm(i18n.t('deleteMsgBox.content'), i18n.t('deleteMsgBox.hint'), {
|
||||
confirmButtonText: i18n.t('btn.confirm'),
|
||||
cancelButtonText: i18n.t('btn.cancel'),
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
// 走接口
|
||||
const result = await delBOM({
|
||||
id: raw.data.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: i18n.t('deleteMsgBox.doneMsg')
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
this.showEditDialog = true
|
||||
this.curEditId = raw.data.id
|
||||
break
|
||||
case 'detail':
|
||||
this.$router.push({
|
||||
name: 'DeviceBOMManage',
|
||||
query: {
|
||||
id: raw.data.id
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
},
|
||||
async getList() {
|
||||
this.listLoading = true
|
||||
// edit here
|
||||
const res = await getBOMList(objFilter(this.listQuery))
|
||||
if (res.code === 0) {
|
||||
this.list = res.data.records
|
||||
this.total = res.data.total
|
||||
this.listLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.usermanager-container {
|
||||
padding: 20px;
|
||||
.method-btn-area {
|
||||
padding: 15px 30px;
|
||||
margin: 10px 0 20px 0;
|
||||
border: 1px solid #dfe6ec;
|
||||
}
|
||||
}
|
||||
.edit-input {
|
||||
padding-right: 100px;
|
||||
}
|
||||
.cancel-btn {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 10px;
|
||||
}
|
||||
</style>
|
||||
152
src/views/EquipmentManager/BOMManager/subpage/AddForm.vue
Normal file
152
src/views/EquipmentManager/BOMManager/subpage/AddForm.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<!--
|
||||
* @Date: 2021-01-09 16:25:11
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2021-05-19 15:03:21
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\subpage\AddForm.vue
|
||||
* @Description: 子页面
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-bind="$attrs" :title="$t('module.equipmentManager.bomdetail.addDialogTitle')" v-on="$listeners" @open="onOpen" @close="onClose">
|
||||
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="120px">
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.materialName')" prop="materialId">
|
||||
<el-select v-model="formData.materialId" :placeholder="$t('module.equipmentManager.bomdetail.placeholdermaterialName')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.material"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.unit')" prop="unit">
|
||||
<el-select v-model="formData.unit" :placeholder="$t('module.equipmentManager.bomdetail.placeholderunit')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.unit"
|
||||
:key="index"
|
||||
:label="item.dataName"
|
||||
:value="item.dataName"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.quantity')" prop="quantity">
|
||||
<el-input v-model="formData.quantity" type="number" :placeholder="$t('module.equipmentManager.bomdetail.placeholderquantity')" :min="0" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.remark')" prop="remark">
|
||||
<el-input v-model="formData.remark" :placeholder="$t('module.equipmentManager.bomdetail.placeholderremark')" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" :loading="waiting" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { addDeviceBOM } from '@/api/equipment/bom'
|
||||
import { getDictMaterial } from '@/api/dict'
|
||||
import { dataDictionaryDataList } from '@/api/basicData/dataDictionary'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
targetInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
waiting: false,
|
||||
formData: {
|
||||
materialId: null,
|
||||
unit: undefined,
|
||||
quantity: undefined,
|
||||
remark: undefined,
|
||||
equipmentBomId: undefined
|
||||
},
|
||||
rules: {
|
||||
materialId: [{
|
||||
required: true,
|
||||
message: i18n.t('module.equipmentManager.bomdetail.placeholdermaterialName'),
|
||||
trigger: 'change'
|
||||
}],
|
||||
unit: [{
|
||||
required: false,
|
||||
message: i18n.t('module.equipmentManager.bomdetail.placeholderunit'),
|
||||
trigger: 'blur'
|
||||
}],
|
||||
quantity: [{
|
||||
required: false,
|
||||
trigger: 'blur'
|
||||
}],
|
||||
remark: [{
|
||||
required: false,
|
||||
message: i18n.t('module.equipmentManager.bomdetail.placeholderremark'),
|
||||
trigger: 'blur'
|
||||
}]
|
||||
},
|
||||
dict: {
|
||||
material: [],
|
||||
unit: []
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {
|
||||
this.getDict()
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.formData.equipmentBomId = this.targetInfo.id
|
||||
},
|
||||
onClose() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
this.waiting = true
|
||||
this.$refs['elForm'].validate(async valid => {
|
||||
if (!valid) {
|
||||
this.waiting = false
|
||||
return
|
||||
}
|
||||
const result = await addDeviceBOM(this.formData)
|
||||
this.waiting = false
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
})
|
||||
this.$emit('done')
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getDict() {
|
||||
const result = await getDictMaterial()
|
||||
this.dict.material = result
|
||||
const listQuery = {
|
||||
current: 1,
|
||||
size: 500
|
||||
}
|
||||
await dataDictionaryDataList(Object.assign(listQuery, {
|
||||
dictTypeId: '1392033901169348609'
|
||||
})).then(response => {
|
||||
if (response.data.records) {
|
||||
this.dict.unit = response.data.records
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
159
src/views/EquipmentManager/BOMManager/subpage/EditForm.vue
Normal file
159
src/views/EquipmentManager/BOMManager/subpage/EditForm.vue
Normal file
@@ -0,0 +1,159 @@
|
||||
<!--
|
||||
* @Date: 2021-01-09 16:25:11
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2021-05-13 15:00:54
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\subpage\EditForm.vue
|
||||
* @Description: 子页面
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog v-bind="$attrs" :title="$t('module.equipmentManager.bomdetail.editDialogTitle')" v-on="$listeners" @open="onOpen" @close="onClose">
|
||||
<el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="120px">
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.materialName')" prop="materialId">
|
||||
<el-select v-model="formData.materialId" :placeholder="$t('module.equipmentManager.bomdetail.placeholdermaterialName')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.material"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.unit')" prop="unit">
|
||||
<el-select v-model="formData.unit" :placeholder="$t('module.equipmentManager.bomdetail.placeholderunit')" clearable :style="{width: '100%'}">
|
||||
<el-option
|
||||
v-for="(item, index) in dict.unit"
|
||||
:key="index"
|
||||
:label="item.dataName"
|
||||
:value="item.dataName"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.quantity')" prop="quantity">
|
||||
<el-input v-model="formData.quantity" :placeholder="$t('module.equipmentManager.bomdetail.placeholderquantity')" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bomdetail.remark')" prop="remark">
|
||||
<el-input v-model="formData.remark" :placeholder="$t('module.equipmentManager.bomdetail.placeholderremark')" clearable :style="{width: '100%'}" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer">
|
||||
<el-button @click="close">{{ 'btn.cancel' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">{{ 'btn.confirm' | i18nFilter }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { editDeviceBOM, getDeviceBOMInfo } from '@/api/equipment/bom'
|
||||
import { dataDictionaryDataList } from '@/api/basicData/dataDictionary'
|
||||
import { getDictMaterial } from '@/api/dict'
|
||||
export default {
|
||||
components: {},
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
targetInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
materialId: undefined,
|
||||
unit: undefined,
|
||||
quantity: undefined,
|
||||
remark: undefined,
|
||||
id: undefined,
|
||||
equipmentId: undefined
|
||||
},
|
||||
rules: {
|
||||
materialId: [{
|
||||
required: true,
|
||||
message: '请输入物料名称',
|
||||
trigger: 'change'
|
||||
}],
|
||||
unit: [{
|
||||
required: false,
|
||||
message: '请输入单位',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
quantity: [{
|
||||
required: false,
|
||||
trigger: 'blur'
|
||||
}],
|
||||
remark: [{
|
||||
required: false,
|
||||
message: '请输入备注',
|
||||
trigger: 'blur'
|
||||
}]
|
||||
},
|
||||
dict: {
|
||||
unit: [],
|
||||
material: []
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {
|
||||
},
|
||||
mounted() {
|
||||
this.getDict()
|
||||
},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.formData
|
||||
this.getInfo()
|
||||
},
|
||||
onClose() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
this.$refs['elForm'].validate(async valid => {
|
||||
if (!valid) return
|
||||
const result = await editDeviceBOM(this.formData)
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
})
|
||||
this.$emit('done')
|
||||
this.close()
|
||||
}
|
||||
})
|
||||
},
|
||||
async getInfo() {
|
||||
const result = await getDeviceBOMInfo({
|
||||
id: this.targetInfo?.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.formData = result.data
|
||||
}
|
||||
},
|
||||
async getDict() {
|
||||
const result = await getDictMaterial()
|
||||
this.dict.material = result
|
||||
const listQuery = {
|
||||
current: 1,
|
||||
size: 500
|
||||
}
|
||||
await dataDictionaryDataList(Object.assign(listQuery, {
|
||||
dictTypeId: '1392033901169348609'
|
||||
})).then(response => {
|
||||
if (response.data.records) {
|
||||
this.dict.unit = response.data.records
|
||||
}
|
||||
})
|
||||
// const result2 = await getDictUnit()
|
||||
// this.dict.unit = result2.records
|
||||
// console.log(this.dict.unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
232
src/views/EquipmentManager/BOMManager/subpage/detail.vue
Normal file
232
src/views/EquipmentManager/BOMManager/subpage/detail.vue
Normal file
@@ -0,0 +1,232 @@
|
||||
<!--
|
||||
* @Date: 2020-12-15 15:36:52
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2021-07-06 17:21:36
|
||||
* @FilePath: \basic-admin\src\views\EquipmentManager\BOMManager\subpage\detail.vue
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<div class="bom-form-container">
|
||||
<el-form ref="elForm" :model="formData" size="medium" label-width="150px">
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.equipmentName')" prop="equipmentName">
|
||||
<el-input :value="equipmentName" :style="{width: '100%'}" :disabled="pagetype" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.code')" prop="code">
|
||||
<el-input v-model="formData.code" :style="{width: '100%'}" :disabled="pagetype" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.name')" prop="name">
|
||||
<el-input v-model="formData.name" :style="{width: '100%'}" :disabled="pagetype" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.enabled')" prop="enabled" required>
|
||||
<el-switch v-model="formData.enabled" :disabled="pagetype" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('module.equipmentManager.bom.remark')" prop="remark">
|
||||
<el-input v-model="formData.remark" :style="{width: '100%'}" :disabled="pagetype" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="sub-table-container">
|
||||
<el-divider>{{ $t('module.equipmentManager.bomdetail.title') }}</el-divider>
|
||||
<div class="method-btn-area">
|
||||
<el-button type="primary" style="float: right;margin: 0 20px;" @click="showDialog = true">{{ 'btn.add' | i18nFilter }}</el-button>
|
||||
<el-button type="primary" plain icon="el-icon-arrow-left" @click="turnBack">{{ 'btn.back' | i18nFilter }}</el-button>
|
||||
<!-- <el-button style="float: right;" @click="resetForm">重置</el-button> -->
|
||||
</div>
|
||||
<base-table :table-config="tableProps" :table-data="list" :is-loading="listLoading" :page="listQuery.current" :limit="listQuery.size">
|
||||
<method-btn slot="handleBtn" :method-list="tableBtn" @clickBtn="handleClick" />
|
||||
</base-table>
|
||||
</div>
|
||||
<pagination :total="total" :page.sync="listQuery.current" :limit.sync="listQuery.size" @pagination="getList" />
|
||||
<add-form :visible.sync="showDialog" :target-info="{id: listQuery.id}" @done="getList" />
|
||||
<edit-form :visible.sync="showEditDialog" :target-info="{id: curEditId, fatherId: listQuery.id}" @done="getList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import CheckDetail from '@/components/BaseTable/subcomponents/CheckDetail'
|
||||
// import dataDict from '@/filters/DataDict'
|
||||
// edit here
|
||||
const tableBtn = [{
|
||||
type: 'edit',
|
||||
btnName: 'btn.edit'
|
||||
}, {
|
||||
type: 'delete',
|
||||
btnName: 'btn.delete'
|
||||
}]
|
||||
const tableProps = [{
|
||||
prop: 'materialCode',
|
||||
label: i18n.t('module.equipmentManager.bomdetail.materialId'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'materialName',
|
||||
label: i18n.t('module.equipmentManager.bomdetail.materialName'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'unit',
|
||||
label: i18n.t('module.equipmentManager.bomdetail.unit'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'quantity',
|
||||
label: i18n.t('module.equipmentManager.bomdetail.quantity'),
|
||||
align: 'center'
|
||||
}, {
|
||||
prop: 'remark',
|
||||
label: i18n.t('module.equipmentManager.bomdetail.remark'),
|
||||
align: 'center'
|
||||
}]
|
||||
import AddForm from './AddForm'
|
||||
import EditForm from './EditForm'
|
||||
import BaseTable from '@/components/BaseTable'
|
||||
// edit here
|
||||
// import { objFilter } from '@/utils'
|
||||
import { getDeviceBOMList, delDeviceBOM, getBOMInfo } from '@/api/equipment/bom'
|
||||
import { getDictDevice } from '@/api/dict'
|
||||
import { dictChange, dictFilter } from '@/utils'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import MethodBtn from '@/components/BaseTable/subcomponents/MethodBtn'
|
||||
import i18n from '@/lang'
|
||||
export default {
|
||||
name: 'BOMForm',
|
||||
components: { Pagination, BaseTable, MethodBtn, AddForm, EditForm },
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
tableBtn,
|
||||
tableProps,
|
||||
list: [],
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
showDialog: false,
|
||||
curEditId: null,
|
||||
showEditDialog: false,
|
||||
listQuery: {
|
||||
enabled: 1,
|
||||
id: null,
|
||||
current: 1,
|
||||
size: 10,
|
||||
keywords: ''
|
||||
},
|
||||
equipmentName: undefined,
|
||||
formData: {
|
||||
equipmentCode: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
enabled: 1,
|
||||
remark: undefined
|
||||
},
|
||||
dict: {
|
||||
deviceTable: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pagetype() {
|
||||
return true
|
||||
// return false
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
console.log(this.$route.query)
|
||||
this.listQuery.id = this.$route.query.id
|
||||
this.listQuery.keywords = this.$route.query.id
|
||||
await this.getDict()
|
||||
await this.getDetail()
|
||||
await this.getList()
|
||||
// this.listLoading = false
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
handleClick(raw) {
|
||||
console.log(raw)
|
||||
switch (raw.type) {
|
||||
case 'delete':
|
||||
this.$confirm(i18n.t('deleteMsgBox.content'), i18n.t('deleteMsgBox.hint'), {
|
||||
confirmButtonText: i18n.t('btn.confirm'),
|
||||
cancelButtonText: i18n.t('btn.cancel'),
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
// 走接口
|
||||
const result = await delDeviceBOM({
|
||||
id: raw.data.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: i18n.t('deleteMsgBox.doneMsg')
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
this.showEditDialog = true
|
||||
this.curEditId = raw.data.id
|
||||
break
|
||||
}
|
||||
},
|
||||
async getList() {
|
||||
this.listLoading = true
|
||||
// edit here
|
||||
const res = await getDeviceBOMList(this.listQuery)
|
||||
if (res.code === 0) {
|
||||
this.list = res.data.records
|
||||
this.total = res.data.total
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
async getDetail() {
|
||||
const result = await getBOMInfo({
|
||||
id: this.listQuery.id
|
||||
})
|
||||
if (result.code === 0) {
|
||||
this.formData = result.data
|
||||
this.equipmentName = dictFilter(this.dict.deviceTable, { key: 'id', value: 'name' })(result.data.equipmentId)
|
||||
// console.log(result)
|
||||
}
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
if (!valid) return
|
||||
// TODO 提交表单
|
||||
})
|
||||
},
|
||||
resetForm() {
|
||||
this.$refs['elForm'].resetFields()
|
||||
},
|
||||
saveForm() {},
|
||||
async getDict() {
|
||||
const result = await getDictDevice({
|
||||
current: 1,
|
||||
size: 999
|
||||
})
|
||||
this.dict.deviceTable = dictChange(result, { key: 'id', value: 'name' })
|
||||
},
|
||||
turnBack() {
|
||||
this.$router.go(-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "@/styles/mixin.scss";
|
||||
.bom-form-container {
|
||||
padding: 20px;
|
||||
.method-btn-area {
|
||||
padding: 15px 30px;
|
||||
margin: 10px 0 20px 0;
|
||||
border: 1px solid #dfe6ec;
|
||||
@include clearfix;
|
||||
}
|
||||
.sub-table-container {
|
||||
margin-top: 80px;
|
||||
}
|
||||
}
|
||||
.edit-input {
|
||||
padding-right: 100px;
|
||||
}
|
||||
.cancel-btn {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 10px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user