| | |
| | | <div class="main-card"> |
| | | <el-row class="cardTop"> |
| | | <el-col :span="12" class="mainCardBtn"> |
| | | <el-button type="primary" :icon="Plus" size="default" @click="dialogAddRecord = true">新增</el-button> |
| | | <el-button type="primary" :icon="Plus" size="default" @click="addRecordBtn">新增</el-button> |
| | | <!-- <el-button type="warning" :icon="Edit" size="default" plain>修改</el-button>--> |
| | | <!-- <el-button type="danger" :icon="Delete" size="default" plain @click="deleteBatchBtn">删除</el-button>--> |
| | | </el-col> |
| | |
| | | <div>必选</div> |
| | | <div> |
| | | <div v-if="mustList.length>0" v-for="(i,index) in mustList" :key="index"> |
| | | {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'费耗材'}} |
| | | {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'非耗材'}} |
| | | </div> |
| | | <div v-else> |
| | | 无 |
| | |
| | | <div>可选</div> |
| | | <div> |
| | | <div v-if="chooseList.length>0" v-for="(i,index) in chooseList" :key="index"> |
| | | {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'费耗材'}} |
| | | {{i.materialName}}:默认值:{{i.defaultVal}},{{i.consumables?'耗材':'非耗材'}} |
| | | </div> |
| | | <div v-else> |
| | | 无 |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="描述"> |
| | | <el-input v-model="details.info" type="textarea" autosize readonly /> |
| | | </el-form-item> |
| | | <el-form-item label="创建人"> |
| | | <el-input v-model="details.createUname" readonly /> |
| | |
| | | <el-form-item label="物资标准配置"> |
| | | <el-tabs tab-position="left" class="demo-tabs" type="border-card"> |
| | | <el-tab-pane v-for="(item,index) in allList" :label="item.materialTypeName" :key="index"> |
| | | <div v-for="(i,x) in item.list" :key="x"> |
| | | <el-checkbox :label="i.name" v-model="checkData[index].list[x].checked"> |
| | | <div>{{i.name}}</div> |
| | | <div><span>默认值:</span><el-input size="small" v-model="checkData[index].list[x].defaultVal"/></div> |
| | | <div> |
| | | <span>配置级别:</span> |
| | | <el-select size="small" v-model="checkData[index].list[x].configurationLevel"> |
| | | <div class="tab-i" v-for="(i,x) in item.list" :key="x"> |
| | | <el-checkbox :label="i.materialName" v-model="checkData[index].list[x].checked"> |
| | | </el-checkbox> |
| | | <el-form v-if="checkData[index].list[x].checked" :model="checkData[index].list[x]" label-width="100px" ref="addListRef" :rules="addListRules"> |
| | | <el-form-item label="默认值" prop="defaultVal"><el-input v-model="checkData[index].list[x].defaultVal"/></el-form-item> |
| | | <el-form-item label="配置级别" prop="configurationLevel"> |
| | | <el-select v-model="checkData[index].list[x].configurationLevel"> |
| | | <el-option key="0" label="必选" value="0"/> |
| | | <el-option key="1" label="可选" value="1"/> |
| | | <el-option key="2" label="高配" value="2"/> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <span>是否耗材:</span> |
| | | <el-radio-group v-model="checkData[index].list[x].consumables" class="ml-4"> |
| | | <el-radio label="1">是</el-radio> |
| | | <el-radio label="2">否</el-radio> |
| | | </el-form-item> |
| | | <el-form-item label="是否耗材" prop="consumables"> |
| | | <el-radio-group v-model="checkData[index].list[x].consumables"> |
| | | <el-radio :label=true>是</el-radio> |
| | | <el-radio :label=false>否</el-radio> |
| | | </el-radio-group> |
| | | </div> |
| | | </el-checkbox> |
| | | </el-form-item> |
| | | <!-- <div>--> |
| | | <!-- <span>配置级别:</span>--> |
| | | <!-- <el-select size="small" v-model="checkData[index].list[x].configurationLevel">--> |
| | | <!-- <el-option key="0" label="必选" value="0"/>--> |
| | | <!-- <el-option key="1" label="可选" value="1"/>--> |
| | | <!-- <el-option key="2" label="高配" value="2"/>--> |
| | | <!-- </el-select>--> |
| | | <!-- </div>--> |
| | | <!-- <div>--> |
| | | <!-- <span>是否耗材:</span>--> |
| | | <!-- <el-radio-group v-model="checkData[index].list[x].consumables">--> |
| | | <!-- <el-radio label="1">是</el-radio>--> |
| | | <!-- <el-radio label="2">否</el-radio>--> |
| | | <!-- </el-radio-group>--> |
| | | <!-- </div>--> |
| | | </el-form> |
| | | </div> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | | </el-form-item> |
| | | <el-form-item label="描述" prop="describe"> |
| | | <el-input v-model="addRecord.describe" type="textarea" autosize :rows="2"/> |
| | | <el-form-item label="描述" prop="info"> |
| | | <el-input v-model="addRecord.info" type="textarea" autosize :rows="2"/> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="warning" @click="dialogAddRecord = false" size="default" plain>取消</el-button> |
| | |
| | | // }; |
| | | |
| | | const addRef = ref<FormInstance>(); |
| | | const addListRef = ref<FormInstance>(); |
| | | const addRules = reactive<FormRules>({ |
| | | name: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], |
| | | workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], |
| | | workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }] |
| | | }); |
| | | const addListRules = reactive<FormRules>({ |
| | | defaultVal: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], |
| | | configurationLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }], |
| | | consumables: [{ required: true, message: '该内容不能为空', trigger: 'blur' }] |
| | | }); |
| | | const addNoRules = reactive<FormRules>({}); |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | getListByPage(); |
| | | getList(); |
| | | getListByPage() |
| | | }); |
| | | |
| | | const toType = (row, column, cellValue, index) => { |
| | |
| | | let res = await materialApi().getRecordList(); |
| | | if (res.data.code === '200') { |
| | | state.allList = JSON.parse(JSON.stringify(res.data.data)) |
| | | // const test = [{id:1,name:'1',children:[{one:1,two:'1'},]},{id:2,name:'2',children:[{one:2,two:'2'},]}] |
| | | // test.map(item => { |
| | | // item.children.map(i =>{ |
| | | // debugger |
| | | // return { |
| | | // three:true |
| | | // } |
| | | // const obj = i |
| | | // console.log(obj); |
| | | // }) |
| | | // return item |
| | | // }) |
| | | // console.log(test); |
| | | for(let i in state.allList){ |
| | | state.allList[i].list = state.allList[i].list?.map((item:any) => { |
| | | const obj = { |
| | | checked: false, |
| | | materialName: item.name, |
| | | consumables: false, |
| | | consumables: null, |
| | | defaultVal: null, |
| | | configurationLevel: null, |
| | | materialType: item.materialType, |
| | |
| | | }) |
| | | } |
| | | state.checkData = JSON.parse(JSON.stringify(state.allList)) |
| | | // state.checkData = state.allList.map((item)=>{ |
| | | // if(item.list && item.list != null){ |
| | | // console.log('1111111111111') |
| | | // item.list.map((i)=>{ |
| | | // i.checked = false |
| | | // i.defaultVal = null |
| | | // i.configurationLevel = null |
| | | // i.consumables = false |
| | | // debugger |
| | | // const obj = { |
| | | // checked: i.checked, |
| | | // materialName: i.name, |
| | | // consumables: i.consumables, |
| | | // defaultVal: i.defaultVal, |
| | | // configurationLevel: i.configurationLevel, |
| | | // materialType: i.materialType, |
| | | // materialTypeName: i.materialTypeName, |
| | | // emergencyMaterialId: i.id |
| | | // } |
| | | // return {...obj} |
| | | // }) |
| | | // } |
| | | // return item |
| | | // }) |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | console.log(state.checkData,'state.checkData') |
| | | } |
| | | |
| | | // 分页获取物资标准列表 |
| | |
| | | getListByPage(); |
| | | }; |
| | | |
| | | const addRecordBtn = () =>{ |
| | | getList() |
| | | state.dialogAddRecord = true |
| | | } |
| | | |
| | | // 添加方法 |
| | | const addRecord = async (data: any) => { |
| | | let res = await materialApi().addRecord(data); |
| | |
| | | |
| | | // 修改方法 |
| | | const editRecordBtn = async (index, row) => { |
| | | getList() |
| | | state.addRecord = JSON.parse(JSON.stringify(row)); |
| | | console.log(state.addRecord,'state.addRecord') |
| | | state.dialogAddRecord = true; |
| | | state.chosenIndex = index; |
| | | }; |
| | | |
| | | const editRecord = async (data: any) => { |
| | | let res = await teamManageApi().updateRecord(data); |
| | | let res = await materialApi().updateRecord(data); |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | |
| | | if (!formEl) return; |
| | | await formEl.validate(async (valid, fields) => { |
| | | if (valid) { |
| | | state.addRecord.materialDetailList = [] |
| | | for(let i in state.checkData){ |
| | | if(state.checkData[i].list && state.checkData[i].list.length>0){ |
| | | for(let j=0;j<state.checkData[i].list.length;j++){ |
| | | if(state.checkData[i].list[j].checked){ |
| | | delete state.checkData[i].list[j].checked |
| | | state.checkData[i].list[j].checked |
| | | state.addRecord.materialDetailList.push(state.checkData[i].list[j]) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | const data = { |
| | | name: state.addRecord.name, |
| | | workType: state.addRecord.workType, |
| | | workLevel: state.addRecord.workLevel, |
| | | describe: state.addRecord.describe, |
| | | materialDetailList: [] |
| | | info: state.addRecord.info, |
| | | materialDetailList: state.addRecord.materialDetailList |
| | | }; |
| | | // for(let i=0;i<state.checkData.length;i++){ |
| | | // if(state.checkData[i].list !=null && state.checkData[i].list.length>0){ |
| | | // for(let j=0;j<state.checkData[i].list.length;j++){ |
| | | // if(state.checkData[i].list[j].checked){ |
| | | // let {materialName,consumables,defaultVal,configurationLevel,materialType,materialTypeName,id} = state.checkData[i].list[j] |
| | | // const newObj = {materialName,consumables,defaultVal,configurationLevel,materialType,materialTypeName,id} |
| | | // data.materialDetailList.push({ materialName, consumables, defaultVal, configurationLevel, materialType, materialTypeName, id}) |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | console.log(data,'data>>>>>>>>>') |
| | | // if (state.chosenIndex == null) { |
| | | // await addRecord(data); |
| | | // } else { |
| | | // data.groupId = JSON.stringify(state.addRecord.groupId); |
| | | // await editRecord(data); |
| | | // } |
| | | if(data.materialDetailList.length==0){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '物资配置数据为空' |
| | | }); |
| | | return |
| | | } |
| | | if (state.chosenIndex == null) { |
| | | await addRecord(data); |
| | | } else { |
| | | data.id = state.addRecord.id; |
| | | await editRecord(data); |
| | | } |
| | | state.dialogAddRecord = false; |
| | | } else { |
| | | console.log('error submit!', fields); |
| | |
| | | |
| | | } |
| | | } |
| | | console.log(state.mustList,state.chooseList,state.highList,'666666666') |
| | | state.dialogDetails = true; |
| | | }; |
| | | |
| | |
| | | }; |
| | | return { |
| | | addRef, |
| | | addListRef, |
| | | addRules, |
| | | addListRules, |
| | | addNoRules, |
| | | View, |
| | | Edit, |
| | | Delete, |
| | | Refresh, |
| | | Plus, |
| | | addRecordBtn, |
| | | toType, |
| | | toLevel, |
| | | searchRecord, |
| | |
| | | width: 100% !important; |
| | | } |
| | | |
| | | .el-checkbox{ |
| | | width: 100%; |
| | | .tab-i{ |
| | | margin-bottom: 20px; |
| | | display: flex; |
| | | align-items: flex-start; |
| | | height: auto; |
| | | ::v-deep(.el-checkbox__label){ |
| | | |
| | | .el-form-item{ |
| | | margin-bottom: 20px; |
| | | &>div{ |
| | | width: 100%; |
| | | margin-bottom: 10px; |
| | | &>span{ |
| | | display: inline-block; |
| | | width: 30%; |
| | | } |
| | | .el-input { |
| | | width: 100% !important; |
| | | } |
| | | .el-select { |
| | | width: 100% !important; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |