|
@@ -1,13 +1,6 @@
|
|
|
<template>
|
|
|
- <div class="form">
|
|
|
- <van-nav-bar
|
|
|
- title="工序管理"
|
|
|
- left-text="返回"
|
|
|
- left-arrow
|
|
|
- @click-left="onClickLeft"
|
|
|
- >
|
|
|
- </van-nav-bar>
|
|
|
-
|
|
|
+ <div style="padding-bottom: 60px">
|
|
|
+ <van-nav-bar title="bom管理" left-text="" left-arrow @click-left="onClickLeft"> </van-nav-bar>
|
|
|
<testForm
|
|
|
v-model="formData.data"
|
|
|
:formOption="formOption"
|
|
@@ -16,24 +9,43 @@
|
|
|
@onSubmit="onSubmit"
|
|
|
ref="formDom"
|
|
|
></testForm>
|
|
|
+ <van-popup
|
|
|
+ v-model:show="show"
|
|
|
+ closeable
|
|
|
+ position="bottom"
|
|
|
+ :style="{ height: '60%' }"
|
|
|
+ @close="onClose"
|
|
|
+ >
|
|
|
+ <div style="height: 50px; width: 100px"></div>
|
|
|
+ <van-checkbox-group v-model="formData.data.applicableProductsList">
|
|
|
+ <van-cell-group inset v-for="i in productInfoData" :key="i.id">
|
|
|
+ <van-cell clickable :title="i.name">
|
|
|
+ <template #right-icon>
|
|
|
+ <van-checkbox :name="i.id"></van-checkbox>
|
|
|
+ </template>
|
|
|
+ </van-cell>
|
|
|
+ </van-cell-group>
|
|
|
+ </van-checkbox-group>
|
|
|
+ </van-popup>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
<script setup>
|
|
|
import { ref, getCurrentInstance, onMounted, reactive } from 'vue'
|
|
|
-import { showSuccessToast, showToast } from 'vant'
|
|
|
+import { showSuccessToast, showFailToast,showConfirmDialog } from 'vant'
|
|
|
+import commonList from '@/components/common-list.vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
-import { getUserInfo } from '@/utils/auth'
|
|
|
import testForm from '@/components/testForm/index.vue'
|
|
|
-const proxy = getCurrentInstance().proxy
|
|
|
+import { getUserInfo } from '@/utils/auth'
|
|
|
+const loading = ref(false)
|
|
|
const route = useRoute()
|
|
|
-const show = ref(false)
|
|
|
-const typeModal = ref(false)
|
|
|
-const unitModal = ref(false)
|
|
|
-const classification = ref([])
|
|
|
-const formData = reactive({
|
|
|
- data: {},
|
|
|
+const req = ref({
|
|
|
+ pageNum: 1,
|
|
|
+ keyword: null,
|
|
|
})
|
|
|
+let show = ref(false)
|
|
|
+const finished = ref(false)
|
|
|
+const classification = ref([])
|
|
|
+const proxy = getCurrentInstance().proxy
|
|
|
const formDom = ref(null)
|
|
|
const formOption = reactive({
|
|
|
readonly: false, //用于控制整个表单是否只读
|
|
@@ -42,92 +54,176 @@ const formOption = reactive({
|
|
|
scroll: true,
|
|
|
labelWidth: '62pk',
|
|
|
// hiddenSubmitBtn: true,
|
|
|
+ btnConfig: {
|
|
|
+ isNeed: true,
|
|
|
+ label: '明细',
|
|
|
+ prop: 'bomDetailList',
|
|
|
+ plain: true,
|
|
|
+ // itemType: "default",
|
|
|
+ listConfig: [
|
|
|
+ {
|
|
|
+ type: 'input',
|
|
|
+ itemType: 'text',
|
|
|
+ label: '物料编码',
|
|
|
+ prop: 'code',
|
|
|
+ clearable: true,
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'input',
|
|
|
+ label: '物料名称',
|
|
|
+ prop: 'name',
|
|
|
+ itemType: 'text',
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'picker',
|
|
|
+ label: '单位',
|
|
|
+ prop: 'unit',
|
|
|
+ itemType: 'onePicker',
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: 'dictValue',
|
|
|
+ value: 'dictKey',
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'input',
|
|
|
+ label: '数量',
|
|
|
+ prop: 'quantity',
|
|
|
+ itemType: 'number',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'input',
|
|
|
+ label: '成本',
|
|
|
+ prop: 'cost',
|
|
|
+ itemType: 'number',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ clickFn: () => {
|
|
|
+ show.value = true
|
|
|
+ },
|
|
|
+ },
|
|
|
})
|
|
|
+const onClickLeft = () => history.go(-1)
|
|
|
+const onClose = () => {
|
|
|
+ formData.data.bomDetailList = []
|
|
|
+ if(formData.data.applicableProductsList.length == 0) return
|
|
|
+ formData.data.applicableProductsList.map((id) => {
|
|
|
+ productInfoData.value.forEach((item) => {
|
|
|
+ if (item.id === id) {
|
|
|
+ formData.data.bomDetailList.push({
|
|
|
+ productId: item.id,
|
|
|
+ name: item.name,
|
|
|
+ code: item.code,
|
|
|
+ quantity: null,
|
|
|
+ cost: null,
|
|
|
+ unit: item.unit,
|
|
|
+ deleteFn:function(index,item){
|
|
|
+ //删除对应索引的数据
|
|
|
+ formData.data.bomDetailList.splice(index,1)
|
|
|
+ formData.data.applicableProductsList.splice(index,1)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ formData.data.bomDetailList.map (item=>{
|
|
|
+ for (let i = 0; i < formOption.btnConfig.listConfig[2].data.length; i++) {
|
|
|
+ const element = formOption.btnConfig.listConfig[2].data[i];
|
|
|
+ if(item.unit == element.dictKey){
|
|
|
+ item.unitName = element.dictValue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const getDict = () => {
|
|
|
+ proxy
|
|
|
+ .post('/dictTenantData/page', {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 999,
|
|
|
+ tenantId: getUserInfo().tenantId,
|
|
|
+ dictCode: 'unit',
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ formOption.btnConfig.listConfig[2].data = res.data.rows
|
|
|
+ })
|
|
|
+}
|
|
|
+getDict()
|
|
|
const formConfig = reactive([
|
|
|
-
|
|
|
- {
|
|
|
- type: 'input',
|
|
|
- itemType: 'text',
|
|
|
- label: '车间名称',
|
|
|
- prop: 'name',
|
|
|
- clearable: true,
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'input',
|
|
|
- itemType: 'textarea',
|
|
|
- label: '备注',
|
|
|
- prop: 'remarks',
|
|
|
- },
|
|
|
{
|
|
|
- type: 'upload',
|
|
|
- label: '文件上传',
|
|
|
- prop: 'fileList',
|
|
|
+ type: 'picker',
|
|
|
+ label: '产品名称',
|
|
|
+ prop: 'productId',
|
|
|
+ itemType: 'onePicker',
|
|
|
+ showPicker: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: 'name',
|
|
|
+ value: 'id',
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
},
|
|
|
-
|
|
|
])
|
|
|
const rules = {
|
|
|
- name: [{ required: true, message: '车间类型不能为空' }],
|
|
|
- fileList: [{ required: true, message: '请上传工序文件' }],
|
|
|
+ quantity: [{ required: true, message: '请填写数量' }],
|
|
|
+ cost: [{ required: true, message: '请填写成本' }],
|
|
|
}
|
|
|
-const unitList = ref([])
|
|
|
-
|
|
|
-const getUserList = () => {
|
|
|
+const formData = reactive({
|
|
|
+ data: {
|
|
|
+ addType:1,
|
|
|
+ },
|
|
|
+})
|
|
|
+let productInfoData = ref([])
|
|
|
+const getDtl = (id) => {
|
|
|
+ proxy
|
|
|
+ .post('/productInfo/page', { pageNum: 1, pageSize: 10000 })
|
|
|
+ .then((resDetail) => {
|
|
|
+ productInfoData.value = resDetail.data.rows
|
|
|
+ })
|
|
|
proxy
|
|
|
- .get('/system/user/list?pageNum=1&pageSize=10000', {
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- formConfig[2].data = res.rows
|
|
|
- })
|
|
|
-}
|
|
|
-getUserList()
|
|
|
-const fileList = ref([])
|
|
|
-const onOversize = () => {
|
|
|
- showToast('文件大小不能超过 5MB')
|
|
|
+ .post('/productInfo/page', { pageNum: 1, pageSize: 10000,definition:'1', })
|
|
|
+ .then((resDetail) => {
|
|
|
+ formConfig[0].data = resDetail.data.rows
|
|
|
+ })
|
|
|
}
|
|
|
-const onClickLeft = () => history.back()
|
|
|
+getDtl()
|
|
|
const onSubmit = () => {
|
|
|
- console.log(formData)
|
|
|
-
|
|
|
- proxy.post('/productionProcesses/' + route.query.type, formData.data).then(() => {
|
|
|
- showSuccessToast(route.query.type === 'add' ? '添加成功' : '修改成功')
|
|
|
- setTimeout(() => {
|
|
|
- history.back()
|
|
|
- }, 500)
|
|
|
- })
|
|
|
-}
|
|
|
-const treeToList = (arr) => {
|
|
|
- let res = [] // 用于存储递归结果(扁平数据)
|
|
|
- // 递归函数
|
|
|
- let fn = (source) => {
|
|
|
- source.forEach((el) => {
|
|
|
- res.push(el)
|
|
|
- el.children && el.children.length > 0 ? fn(el.children) : '' // 子级递归
|
|
|
- })
|
|
|
- }
|
|
|
- fn(arr)
|
|
|
- return res
|
|
|
+ formData.data.addType = route.query.addType
|
|
|
+ proxy
|
|
|
+ .post('/bomInfo/' + route.query.type, formData.data)
|
|
|
+ .then(() => {
|
|
|
+ showSuccessToast(
|
|
|
+ route.query.type === 'add' ? '添加成功' : '修改成功'
|
|
|
+ )
|
|
|
+ setTimeout(() => {
|
|
|
+ history.back()
|
|
|
+ }, 500)
|
|
|
+ }).catch(err=>{
|
|
|
+ showFailToast(err.message)
|
|
|
+ })
|
|
|
}
|
|
|
+// getList();
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
- if (route.query.id) {
|
|
|
+ if (route.query.type === 'edit') {
|
|
|
+ loading.value = true
|
|
|
proxy
|
|
|
- .post('/productionProcesses/detail', { id: route.query.id })
|
|
|
- .then((resDetail) => {
|
|
|
- formData.data = resDetail.data
|
|
|
+ .post('/bomInfo/detail', { id: route.query.id })
|
|
|
+ .then((res) => {
|
|
|
+ formData.data = res.data
|
|
|
+ formData.data.bomDetailList = res.data.bomDetailVoList
|
|
|
+ loading.value = false
|
|
|
})
|
|
|
- proxy.post("/fileInfo/getList", { businessIdList: [route.query.id] }).then((res) => {
|
|
|
- if (res.data[route.query.id] && res.data[route.query.id].length > 0) {
|
|
|
- formData.data.fileList = res.data[route.query.id];
|
|
|
- formData.data.fileList = formData.data.fileList.map((item) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- url: item.fileUrl,
|
|
|
- };
|
|
|
- });
|
|
|
- } else {
|
|
|
- formData.data.fileList = [];
|
|
|
- fileList.value = [];
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.list {
|
|
|
+ min-height: 70vh;
|
|
|
+}
|
|
|
+</style>
|