| New file |
| | |
| | | |
| | | |
| | | <script lang="ts" setup> |
| | | import request from "@/utils/request" |
| | | import deepClone from "@/utils/deepClone" |
| | | import {ElMessage} from "element-plus" |
| | | import {computed, onMounted, ref} from "vue" |
| | | import {useRoute, useRouter} from "vue-router" |
| | | import useUserInfo from "@/stores/userInfo" |
| | | import GlassType from "@/components/sd/product/GlassType.vue" |
| | | import useProductGlassTypeStore from "@/stores/sd/product/productGlassType" |
| | | |
| | | |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | | const value = ref('') |
| | | const options = [ |
| | | { |
| | | value: '原片', |
| | | label: '原片' |
| | | }, |
| | | { |
| | | value: '辅料', |
| | | label: '辅料', |
| | | } |
| | | ] |
| | | |
| | | let BasicData = ref([]) |
| | | |
| | | let ruleForm = ref({ |
| | | id:0, |
| | | type: '', |
| | | json: '' |
| | | |
| | | }) |
| | | |
| | | const userinfo=[] |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | const getWork = () => { |
| | | //页面加载请求 |
| | | request.get(`/BasicWarehouse/BasicWarehouseType/${value.value}`).then((res) => { |
| | | if(res.code==200){ |
| | | BasicData.value = res.data |
| | | for (let i=0;i<BasicData.value.length;i++){ |
| | | BasicData.value[i].Type=userinfo[i] |
| | | } |
| | | |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const resetForm = () => { |
| | | BasicData.value.forEach((item)=>{ |
| | | item.Type="" |
| | | }) |
| | | } |
| | | |
| | | const submitForm = () => { |
| | | let filterData = {} |
| | | let isBool=true |
| | | let index = 0 |
| | | let productName = "{" |
| | | |
| | | BasicData.value.forEach((item)=>{ |
| | | filterData[item.OperateType]=item.Type |
| | | const customerName = item.Type |
| | | if(customerName === null || customerName === undefined || customerName === ''){ |
| | | ElMessage.error('请输入'+item.OperateTypeName) |
| | | isBool=false |
| | | return |
| | | } |
| | | if(index == BasicData.value.length - 1){ |
| | | productName+='"'+item.OperateType+'":"'+item.Type+'"' |
| | | }else { |
| | | productName+='"'+item.OperateType+'":"'+item.Type+'",' |
| | | } |
| | | index++; |
| | | }) |
| | | productName+="}" |
| | | |
| | | let materialStore={ |
| | | id:ruleForm.value.id, |
| | | type:value.value, |
| | | json:productName, |
| | | width:BasicData.value[0].Type, |
| | | height:BasicData.value[1].Type |
| | | } |
| | | console.log(materialStore) |
| | | if(isBool){ |
| | | request.post("/MaterialStore/saveMaterialStore", materialStore).then((res) => { |
| | | if(res.code==200){ |
| | | resetForm() |
| | | ElMessage.success('保存成功') |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //获取传过来的数据进行判断 |
| | | const str = route.query.id |
| | | if (typeof str != 'undefined' && str != null && str !== '' && str !== '\n' && str !== '\r'){ |
| | | ruleForm.value.id = Number(str) |
| | | |
| | | request.post(`/MaterialStore/getSelectMaterialStore/1/100`,ruleForm.value).then((res) => { |
| | | if(res.code==200){ |
| | | ruleForm.value=deepClone(res.data.data[0]) |
| | | value.value=ruleForm.value.type |
| | | const cc= JSON.parse(ruleForm.value.json); |
| | | for (let i in cc){ |
| | | userinfo.push(cc[i]) |
| | | } |
| | | getWork() |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | </script> |
| | | <template> |
| | | |
| | | <div class="center-box"> |
| | | <el-card class="form-card"> |
| | | <el-form size="medium" > |
| | | <div> |
| | | <el-row> |
| | | <el-col :span="4"> |
| | | <el-select v-model="value" placeholder="请选择类别" @change="getWork"> |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | |
| | | <el-divider ></el-divider> <!-- 添加分隔线 --> |
| | | |
| | | <el-row gutter="5" |
| | | v-for="item in BasicData" > |
| | | <el-col :span="4.5" > |
| | | {{item.OperateTypeName}}:<el-input v-model="item.Type" placeholder="请输入数据" style="width: 150px; height: 30px;" /> |
| | | </el-col> |
| | | <el-divider ></el-divider> <!-- 添加分隔线 --> |
| | | |
| | | |
| | | </el-row> |
| | | |
| | | |
| | | <el-row gutter="10" justify="center" > |
| | | <el-col span="4"> |
| | | <el-button id="searchButton" type="primary" @click="resetForm" >重置</el-button> |
| | | </el-col> |
| | | <el-col span="4"> |
| | | <el-button id="searchButton" type="primary" @click="submitForm" >保存</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </el-card> |
| | | </div> |
| | | |
| | | </template> |
| | | <style> |
| | | .centered-box { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | height: 100vh; |
| | | } |
| | | |
| | | .form-card { |
| | | width: 1000px; |
| | | padding: 30px 30px; |
| | | } |
| | | .button-row { |
| | | display: flex; |
| | | justify-content: center; |
| | | margin-top: 20px; |
| | | } |
| | | </style> |