| | |
| | | <template> |
| | | <div class="add_wordshop"> |
| | | <el-dialog :title="editConfig.dialogTitle + '车间管理'" :visible.sync="editConfig.visible" width="30%" |
| | | :before-close="handleClose"> |
| | | <el-form :inline="true" label-width="20%" style="width: 100%;" :model="editConfig.infomitton" :rules="rules" |
| | | ref="ruleForm"> |
| | | <el-form-item label="日期区间" style="width: 100%;" prop="groupNumber"> |
| | | <el-date-picker |
| | | style="width: 100%;" |
| | | v-model="editConfig.infomitton.groupNumber" |
| | | type="daterange" |
| | | range-separator="至" |
| | | <el-dialog :visible.sync="islook" width="38rem" @close="cancelMethod"> |
| | | <div slot="title" class="tac drawerHeader">{{ editRow.title }}机台</div> |
| | | <el-form label-width="100px" :model="form" :rules="rules" ref="form"> |
| | | <el-form-item label="日期区间" style="width: 100%" prop="date"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.date" |
| | | type="daterange" |
| | | range-separator="至" |
| | | value-format="yyyy-MM-dd" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | > |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item prop="workshop" label="车间" style="width: 100%;" > |
| | | <el-select |
| | | :disabled="this.editConfig.dialogTitle==='查看'" v-model="editConfig.infomitton.workshop" value-key="name" placeholder="请选择车间"> |
| | | <el-form-item prop="workshopObj" label="车间"> |
| | | <el-select |
| | | v-model="form.workshopObj" |
| | | placeholder="请选择车间" |
| | | @change="getGroupNumber(false, 'workshopObj')" |
| | | > |
| | | <el-option |
| | | v-for="item in workshopList" |
| | | :key="item.ID" |
| | | v-for="item in shopList" |
| | | :key="item.number" |
| | | :label="item.name" |
| | | :value="item"> |
| | | :value="{ value: item.number, label: item.name }" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item prop="workshop" label="组别" style="width: 100%;" > |
| | | <el-select |
| | | :disabled="this.editConfig.dialogTitle==='查看'" v-model="editConfig.infomitton.groupNumber" value-key="name" placeholder="请选择车间"> |
| | | <el-form-item prop="workshopGroup" label="组别"> |
| | | <el-select |
| | | v-model="form.workshopGroup" |
| | | @change="getGroupNumber(false, 'workshopGroup')" |
| | | placeholder="请先选择车间" |
| | | no-data-text="请先选择车间" |
| | | > |
| | | <el-option |
| | | v-for="item in workshopList" |
| | | :key="item.ID" |
| | | :label="item.name" |
| | | :value="item"> |
| | | v-for="item in groupNumberList" |
| | | :key="item" |
| | | :label="item" |
| | | :value="item" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item prop="workshop" label="机台号" style="width: 100%;" > |
| | | <el-select |
| | | :disabled="this.editConfig.dialogTitle==='查看'" v-model="editConfig.infomitton.groupNumber" value-key="name" placeholder="请选择车间"> |
| | | <el-form-item prop="workerPosition" label="机台号"> |
| | | <el-select |
| | | v-model="form.workerPosition" |
| | | placeholder="请先选择车间和组别" |
| | | no-data-text="请先选择车间和组别" |
| | | > |
| | | <el-option |
| | | v-for="item in workshopList" |
| | | v-for="item in workerPositionList" |
| | | :key="item.ID" |
| | | :label="item.name" |
| | | :value="item"> |
| | | :label="item.carNumber" |
| | | :value="{ value: item.carNumber, label: item.carNumber }" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item prop="workshop" label="员工姓名" style="width: 100%;" > |
| | | <el-select |
| | | :disabled="this.editConfig.dialogTitle==='查看'" v-model="editConfig.infomitton.groupNumber" value-key="name" placeholder="请选择车间"> |
| | | <el-option |
| | | v-for="item in workshopList" |
| | | :key="item.ID" |
| | | :label="item.name" |
| | | :value="item"> |
| | | </el-option> |
| | | </el-select> |
| | | <el-form-item prop="name" label="员工姓名" style="width: 100%"> |
| | | <UserSimpleSearchInput |
| | | :echoValue="form.workerId" |
| | | :echoName="form.name" |
| | | checkedNum="1" |
| | | request="1" |
| | | :clearable="true" |
| | | @select-user="setFormItem($event, 'workerId', 'name')" |
| | | > |
| | | </UserSimpleSearchInput> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="editConfig.visible = false">取 消</el-button> |
| | | <el-button type="primary" @click="commitForm('ruleForm')">确 定</el-button> |
| | | <el-button @click="cancelMethod()">取 消</el-button> |
| | | <el-button type="primary" @click="submitForm('form')">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | // import {} from "@/api/systemSetting/workshopManage" |
| | | import { |
| | | createWorkerPositionInfo, |
| | | updateWorkerPositionInfo, |
| | | } from "@/api/employeeSalary/machineManage.js"; |
| | | import { getWorkshopManageGroup } from "@/api/productManage/productRegisterForm.js"; |
| | | import { getDictList } from "@/api/productManage/silkRegisterForm.js"; |
| | | import { getWorkshopManageList } from "@/api/systemSetting/workshopManage.js"; |
| | | import UserSimpleSearchInput from "@/components/common/UserSimpleSearchInput"; |
| | | export default { |
| | | components: { |
| | | UserSimpleSearchInput, |
| | | }, |
| | | props: { |
| | | editDiaConfig: { |
| | | editRow: { |
| | | type: Object, |
| | | default: () => { |
| | | return { |
| | | visible: false, |
| | | dialogTitle: "添加", |
| | | isReadonly: true, |
| | | infomitton: { |
| | | }, |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | editConfig: this.editDiaConfig, |
| | | workshopList: [], |
| | | carFlagList: [ |
| | | ], |
| | | shopList: [], //车间 |
| | | groupNumberList: [], //组别 |
| | | workerPositionList: [], //机台号 |
| | | islook: false, |
| | | form: { |
| | | date: [], |
| | | workshopObj: {}, |
| | | workshop: "", |
| | | workshopGroup: "", |
| | | workerPosition: "", |
| | | name: "", |
| | | workerId: "", |
| | | }, |
| | | rules: { |
| | | workshopNumber: [ |
| | | { required: true, message: '请选择车间', trigger: 'change' } |
| | | date: [ |
| | | { required: true, message: "请选择", trigger: ["change", "blur"] }, |
| | | ], |
| | | groupNumber: [ |
| | | { required: true, message: '请填写组别', trigger: 'change' } |
| | | ] |
| | | workshopObj: [ |
| | | { required: true, message: "请选择", trigger: ["change", "blur"] }, |
| | | ], |
| | | workshopGroup: [ |
| | | { required: true, message: "请选择", trigger: ["change", "blur"] }, |
| | | ], |
| | | workerPosition: [ |
| | | { required: true, message: "请选择", trigger: ["change", "blur"] }, |
| | | ], |
| | | }, |
| | | }; |
| | | }, |
| | | computed: { |
| | | }, |
| | | computed: {}, |
| | | created() { |
| | | this.getSelectDataList(); |
| | | }, |
| | | mounted() { |
| | | |
| | | }, |
| | | mounted() {}, |
| | | watch: { |
| | | |
| | | islook(newVal) { |
| | | if (newVal) { |
| | | this.formInfo(); |
| | | } |
| | | }, |
| | | editRow() { |
| | | this.formInfo(); |
| | | }, |
| | | }, |
| | | methods: { |
| | | handleClose(done) { |
| | | done(); |
| | | }, |
| | | setParams() { |
| | | let params = { |
| | | workshopNumber: this.editConfig.infomitton.workshopNumber + '', |
| | | groupNumber: Number(this.editConfig.infomitton.groupNumber), |
| | | startCarNumber: Number(this.editConfig.infomitton.startCarNumber), |
| | | endCarNumber: Number(this.editConfig.infomitton.endCarNumber), |
| | | carFlag: Number(this.editConfig.infomitton.carFlag), |
| | | notes: this.editConfig.infomitton.notes, |
| | | // id:Number(this.editConfig.infomitton.workshopId), |
| | | formInfo() { |
| | | if (this.islook) { |
| | | this.form = { |
| | | date: [], |
| | | workshopObj: {}, |
| | | workshop: "", |
| | | workshopGroup: "", |
| | | workerPosition: "", |
| | | workerId: "", |
| | | }; |
| | | this.$nextTick(() => { |
| | | this.$refs["form"].resetFields(); |
| | | if (this.editRow.id) { |
| | | this.form = JSON.parse(JSON.stringify(this.editRow)); |
| | | this.getGroupNumber(true); |
| | | } |
| | | }); |
| | | } |
| | | return params |
| | | }, |
| | | async commitForm(formName) { |
| | | setFormItem(val, itemMark, itemName) { |
| | | this.$set(this.form, itemMark, val.id); |
| | | this.$set(this.form, itemName, val.name); |
| | | }, |
| | | getGroupNumber(val, name) { |
| | | if (name == "workshopObj") { |
| | | this.form.workshopGroup = ""; |
| | | this.form.workerPosition = ""; |
| | | } |
| | | if (name == "workshopGroup") { |
| | | this.form.workerPosition = ""; |
| | | } |
| | | if (Object.keys(this.form.workshopObj).length > 0) { |
| | | //组别 |
| | | getWorkshopManageGroup({ number: this.form.workshopObj.value }).then( |
| | | (res) => { |
| | | if (res.code == 200) { |
| | | let groupNumberList = res.data || {}; |
| | | this.groupNumberList = []; |
| | | if (Object.keys(groupNumberList).length > 0) { |
| | | for (let i in groupNumberList) { |
| | | this.groupNumberList.push(groupNumberList[i]); |
| | | } |
| | | } |
| | | } else { |
| | | this.groupNumberList = []; |
| | | this.form.workshop = ""; |
| | | } |
| | | } |
| | | ); |
| | | if (this.form.workshopGroup) { |
| | | getWorkshopManageList({ |
| | | page: 0, |
| | | pageSize: 0, |
| | | keyWord: "", |
| | | workshopName: this.form.workshopObj.label, |
| | | groupNumber: this.form.workshopGroup, |
| | | }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.workerPositionList = []; |
| | | let data = res.data ? JSON.parse(JSON.stringify(res.data)) : []; |
| | | if (Object.keys(data).length > 0) { |
| | | for (let i in data) { |
| | | this.workerPositionList.push({ |
| | | ID: data[i].ID, |
| | | carNumber: |
| | | data[i].startCarNumber + "-" + data[i].endCarNumber, |
| | | }); |
| | | } |
| | | } |
| | | } else { |
| | | this.workerPositionList = []; |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | this.groupNumberList = []; |
| | | } |
| | | }, |
| | | getSelectDataList() { |
| | | //车间 |
| | | getDictList({ |
| | | dictType: 1, |
| | | }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.shopList = res.data || []; |
| | | } |
| | | }); |
| | | }, |
| | | cancelMethod(val) { |
| | | this.$refs["form"].resetFields(); |
| | | this.islook = false; |
| | | if (val) { |
| | | this.$emit("refresh"); |
| | | } |
| | | }, |
| | | submitForm(formName) { |
| | | this.$refs[formName].validate((valid) => { |
| | | if (valid) { |
| | | console.log("校验通过") |
| | | let form = JSON.parse(JSON.stringify(this.form)); |
| | | form.startDate = form.date.length > 0 ? form.date[0] : ""; |
| | | form.endDate = form.date.length > 0 ? form.date[1] : ""; |
| | | form.startWorkerPosition = form.workerPosition |
| | | ? Number(form.workerPosition.label.split("-")[0]) |
| | | : ""; |
| | | form.endWorkerPosition = form.workerPosition |
| | | ? Number(form.workerPosition.label.split("-")[1]) |
| | | : ""; |
| | | form.workshop = |
| | | Object.keys(form.workshopObj).length > 0 |
| | | ? form.workshopObj.value |
| | | : ""; |
| | | form.workshopName = |
| | | Object.keys(form.workshopObj).length > 0 |
| | | ? form.workshopObj.label |
| | | : ""; |
| | | if (this.editRow.type == "add") { |
| | | createWorkerPositionInfo(form).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "添加成功!", |
| | | type: "success", |
| | | }); |
| | | this.cancelMethod(true); |
| | | } |
| | | }); |
| | | } else { |
| | | updateWorkerPositionInfo(form).then((res) => { |
| | | if (res.code == 200) { |
| | | this.$message({ |
| | | message: "编辑成功!", |
| | | type: "success", |
| | | }); |
| | | this.cancelMethod(true); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | console.log('error submit!!'); |
| | | console.log("error submit!!"); |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }, |
| | | components: { |
| | | |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | ::v-deep .el-form-item__content { |
| | | width: 70% !important; |
| | | .el-form { |
| | | margin-bottom: 50px; |
| | | width: 94%; |
| | | margin: 0 auto; |
| | | } |
| | | |
| | | ::v-deep { |
| | | .el-form { |
| | | .el-input__inner { |