¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <j-modal |
| | | :title="title" |
| | | :width="width" |
| | | :visible="visible" |
| | | :fullscreen="true" |
| | | switchFullscreen |
| | | @ok="handleOk" |
| | | :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" |
| | | @cancel="handleCancel" |
| | | cancelText="å
³é"> |
| | | |
| | | <a-row :gutter="{ xs: 4, sm: 8, md: 16}"> |
| | | <a-col :span="12"> |
| | | <a-card :bordered="false"> |
| | | <!-- æ¥è¯¢åºå --> |
| | | <div class="table-page-search-wrapper"> |
| | | <a-form layout="inline" @keyup.enter.native="searchQuery"> |
| | | <a-row :gutter="12"> |
| | | <a-col :span="7"> |
| | | <a-form-item label="产线" :label-col="{span: 6}" :wrapper-col="{span: 18}"> |
| | | <j-tree-select dict="base_factory,factory_name,id" pid-field="parent_id" |
| | | v-model="queryParam.factoryId" style="width: 100%"></j-tree-select> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="9"> |
| | | <a-form-item label="æ¥æ" :label-col="{span: 4}" :wrapper-col="{span: 20}"> |
| | | <a-range-picker |
| | | style="width: 100%" |
| | | @change="dateRangeChange" |
| | | :value="dateRange" |
| | | :disabledDate="disabledDate" |
| | | @openChange="onOpenChange" |
| | | /> |
| | | </a-form-item> |
| | | </a-col> |
| | | <a-col :span="8"> |
| | | <span style="float: left;overflow: hidden;white-space: nowrap;" class="table-page-search-submitButtons"> |
| | | <a-button type="primary" @click="searchQuery" icon="search">æ¥è¯¢</a-button> |
| | | <a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">éç½®</a-button> |
| | | </span> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row :gutter="12" style="margin-top: 8px;"> |
| | | <a-col :span="24"> |
| | | <a-button type="primary" @click="generatePlan" icon="retweet">çææäº§è®¡å</a-button> |
| | | </a-col> |
| | | </a-row> |
| | | </a-form> |
| | | </div> |
| | | |
| | | <div class="table-operator"> |
| | | <a-dropdown v-if="selectedRowKeys.length > 0"> |
| | | <a-menu slot="overlay"> |
| | | <a-menu-item key="1" @click="batchDel"> |
| | | <a-icon type="delete" /> |
| | | å é¤ |
| | | </a-menu-item> |
| | | </a-menu> |
| | | <a-button style="margin-left: 8px"> æ¹éæä½ |
| | | <a-icon type="down" /> |
| | | </a-button> |
| | | </a-dropdown> |
| | | </div> |
| | | <!-- <div>--> |
| | | <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">--> |
| | | <!-- <i class="anticon anticon-info-circle ant-alert-icon"></i> 已鿩 <a--> |
| | | <!-- style="font-weight: 600">{{ selectedRowKeys.length }}</a>项--> |
| | | <!-- <a style="margin-left: 24px" @click="onClearSelected">æ¸
空</a>--> |
| | | <!-- </div>--> |
| | | |
| | | <vxe-table |
| | | ref="table" |
| | | border |
| | | show-overflow |
| | | show-header-overflow |
| | | :scroll-x="{enabled: true}" |
| | | :data="dataSource" |
| | | :edit-config="{trigger: 'click', mode: 'cell', activeMethod: isRowEditable}" |
| | | :edit-rules="editRules" |
| | | > |
| | | <!-- <vxe-table-column type="checkbox" width="40" fixed="left"></vxe-table-column>--> |
| | | <vxe-table-column type="seq" width="40" /> |
| | | <vxe-table-column width="100" title="å·¥åå·" field="workOrderCode"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.workOrderCode">{{ row.workOrderCode }}</span> |
| | | <span v-else class="placeholder-text">ç³»ç»èªå¨çæ</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column |
| | | title="ç©æç¼å·" |
| | | field="materialNumber" |
| | | width="120" |
| | | :edit-render="{name: '$select', options: materialOptions, events: {change: handleMaterialChange}}"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.materialNumber">{{ row.materialNumber }}</span> |
| | | <span v-else class="placeholder-text">è¯·éæ©ç©æç¼å·</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column title="ç©æåç§°" field="materialName" width="100"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.materialName">{{ row.materialName }}</span> |
| | | <span v-else class="placeholder-text">ç©æåç§°èªå¨å¡«å
</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column title="çç»id" :visible="false" field="groupId"></vxe-table-column> |
| | | <vxe-table-column |
| | | title="çæ¬¡" |
| | | width="100" |
| | | field="shiftId" |
| | | :edit-render="{name: '$select', options: shiftOptions, events: {change: handleShiftChange}}"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.shiftId">{{ row.shiftName || row.shiftId_dictText }}</span> |
| | | <span v-else class="placeholder-text">è¯·éæ©çæ¬¡</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column |
| | | title="æäº§æ¥æ" |
| | | field="workOrderDate" |
| | | width="120" |
| | | :edit-render="{name: '$select', options: workOrderDateOptions, events: {change: handleWorkOrderDateChange}}"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.workOrderDate">{{ row.workOrderDate }}</span> |
| | | <span v-else class="placeholder-text">è¯·éæ©æäº§æ¥æ</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column |
| | | title="计åç产æ°é" |
| | | field="planQuantity" |
| | | width="100" |
| | | :edit-render="{name: '$input'}"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.planQuantity">{{ row.planQuantity }}</span> |
| | | <span v-else class="placeholder-text">请填å计åç产æ°é</span> |
| | | </template> |
| | | </vxe-table-column> |
| | | <vxe-table-column title="" width="40" fixed="right"> |
| | | <template #default="{ row }"> |
| | | <span v-if="row.workOrderStatus === 'NEW' || !row.workOrderStatus"> |
| | | <i class="vxe-icon--remove" @click="handleRemove(row)"></i> |
| | | </span> |
| | | </template> |
| | | </vxe-table-column> |
| | | </vxe-table> |
| | | <a-button |
| | | :disabled="addScheduleFlag" |
| | | style="width: 100%; margin-top: 16px; margin-bottom: 8px" |
| | | type="dashed" |
| | | icon="plus" |
| | | @click="addSchedulePlan" |
| | | >æ°å¢æäº§è®¡å |
| | | </a-button> |
| | | <!-- <vxe-pager--> |
| | | <!-- :current-page="pagination.current"--> |
| | | <!-- :page-size="pagination.pageSize"--> |
| | | <!-- :total="pagination.total"--> |
| | | <!-- :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"--> |
| | | <!-- @page-change="handlePageChange">--> |
| | | <!-- </vxe-pager>--> |
| | | </div> |
| | | </a-card> |
| | | </a-col> |
| | | <a-col :span="12"> |
| | | <a-card :bordered="false"> |
| | | <MesProductionWeekCalendar |
| | | ref="weekCalendar" |
| | | :start-date="calendarStartDate" |
| | | :show-navigation="false" |
| | | :show-today-button="false" |
| | | :show-today-highlight="false" |
| | | :show-first-day-highlight="false" |
| | | @select="onDateSelect" |
| | | @change="onCalendarChange" |
| | | > |
| | | <template #dateCell="{ date, isSelected, isToday }"> |
| | | <div class="custom-date-content"> |
| | | <div |
| | | v-for="(workOrder, index) in getWorkOrdersForDate(date)" |
| | | :key="workOrder.id" |
| | | class="work-order-item" |
| | | :class="getColorClass(index)" |
| | | > |
| | | <span class="work-order-shift">{{ workOrder.shiftCode }}</span> |
| | | <span class="work-order-material">{{ workOrder.materialName }}</span> |
| | | <span class="work-order-quantity">{{ workOrder.planQuantity }}</span> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | </MesProductionWeekCalendar> |
| | | </a-card> |
| | | </a-col> |
| | | </a-row> |
| | | |
| | | </j-modal> |
| | | |
| | | |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import '@/assets/less/TableExpand.less' |
| | | import MesProductionWeekCalendar from '@views/mes/modules/MesProductionWeekCalendar.vue' |
| | | import moment from 'moment' |
| | | import { getAction, postAction, requestPut } from '@api/manage' |
| | | import { ajaxGetDictItems } from '@api/api' |
| | | |
| | | export default { |
| | | name: 'MesProductionWorkOrderScheduleModal', |
| | | components: { |
| | | MesProductionWeekCalendar |
| | | }, |
| | | data() { |
| | | return { |
| | | title: 'æäº§ç®¡ç页é¢', |
| | | width: 600, |
| | | visible: false, |
| | | disableSubmit: false, |
| | | addScheduleFlag: false, |
| | | queryParam: {}, |
| | | dataSource: [], |
| | | shiftOptions: [], |
| | | groupShiftMap: {}, |
| | | materialOptions: [], |
| | | materNumberNameMap: {}, |
| | | workOrderDateOptions: [], |
| | | selectedRowKeys: [], |
| | | selectionRows: [], |
| | | /* å页忰 */ |
| | | pagination: { |
| | | current: 1, |
| | | pageSize: 10, |
| | | total: 0 |
| | | }, |
| | | // 表头 |
| | | url: { |
| | | list: '/mesproductionworkorder/mesProductionWorkOrder/list', |
| | | delete: '/mesproductionworkorder/mesProductionWorkOrder/delete', |
| | | deleteBatch: '/mesproductionworkorder/mesProductionWorkOrder/deleteBatch', |
| | | exportXlsUrl: '/mesproductionworkorder/mesProductionWorkOrder/exportXls', |
| | | importExcelUrl: 'mesproductionworkorder/mesProductionWorkOrder/importExcel', |
| | | listProductionLinesOption: '/base/factory/queryIdTree', |
| | | queryShiftGroupByFactoryId: '/base/shiftGroup/queryShiftGroupByFactoryId', |
| | | queryFactoryById: '/base/factory/queryById', |
| | | schedule: '/mesproductionworkorder/mesProductionWorkOrder/schedule', |
| | | addSchedulePlan: '/mesproductionworkorder/mesProductionWorkOrder/addSchedulePlan' |
| | | }, |
| | | editRules: { |
| | | materialNumber: [ |
| | | { required: true, message: 'ç©æç¼å·å¿
须鿩' } |
| | | ], |
| | | shiftId: [ |
| | | { required: true, message: 'çæ¬¡å¿
须鿩' } |
| | | ], |
| | | workOrderDate: [ |
| | | { required: true, message: 'æäº§æ¥æå¿
须鿩' } |
| | | ], |
| | | planQuantity: [ |
| | | { required: true, message: '计åç产æ°é为å¿
å¡«' } |
| | | ] |
| | | }, |
| | | dictOptions: {}, |
| | | superFieldList: [], |
| | | // ç¨äºæ¼ç¤ºçå·¥åæ°æ® |
| | | workOrdersByDate: {}, |
| | | // æ¥åèµ·å§æ¥æ |
| | | calendarStartDate: moment().startOf('week'), // é»è®¤æ¾ç¤ºå½åå¨çå¨ä¸ |
| | | productionLineData: [], |
| | | dateRange: [], |
| | | tempStartDate: null, // 临æ¶åå¨å¼å§æ¥æ |
| | | hoveredDate: null // åå¨é¼ æ æ¬åçæ¥æ |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | watch: { |
| | | dataSource: { |
| | | handler() { |
| | | // ä½¿ç¨ nextTick ç¡®ä¿å¨ DOM æ´æ°ååæ´æ°æ¥å |
| | | this.$nextTick(() => { |
| | | this.updateCalendarWorkOrders() |
| | | }) |
| | | }, |
| | | deep: true |
| | | } |
| | | }, |
| | | computed: { |
| | | importExcelUrl: function() { |
| | | return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}` |
| | | } |
| | | }, |
| | | methods: { |
| | | isRowEditable({row, rowIndex}) { |
| | | return row.workOrderStatus === 'NEW' || !row.workOrderStatus |
| | | }, |
| | | getColorClass(index) { |
| | | return index % 2 === 0 ? 'blue-item' : 'red-item'; |
| | | }, |
| | | scheduleOpen() { |
| | | this.visible = true |
| | | }, |
| | | close() { |
| | | this.$emit('close') |
| | | this.visible = false |
| | | }, |
| | | handleOk() { |
| | | // è¡¨æ ¼å
¨è¡¨æ ¡éª |
| | | this.$refs.table.validate((valid) => { |
| | | if (valid) { |
| | | this.$message.error("è¯·å®æææå¿
å¡«ä¿¡æ¯ååæäº¤ï¼") |
| | | } else { |
| | | let tableData = this.$refs.table.getTableData().fullData |
| | | postAction(this.url.addSchedulePlan, tableData).then(res=> { |
| | | if (res.success) { |
| | | this.$message.success(res.message) |
| | | this.submitCallback() |
| | | } else { |
| | | this.$message.warning(res.message) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | submitCallback() { |
| | | this.$emit('ok') |
| | | this.queryParam = {} |
| | | this.dateRange = [] |
| | | this.workOrdersByDate = {} |
| | | this.dataSource = [] |
| | | this.visible = false |
| | | }, |
| | | handleCancel() { |
| | | this.queryParam = {} |
| | | this.dateRange = [] |
| | | this.workOrdersByDate = {} |
| | | this.dataSource = [] |
| | | this.pagination.current = 1 |
| | | this.pagination.pageSize = 10 |
| | | this.pagination.total = 0 |
| | | this.close() |
| | | }, |
| | | onClearSelected() { |
| | | this.selectedRowKeys = [] |
| | | this.selectionRows = [] |
| | | }, |
| | | loadData(arg) { |
| | | return new Promise((resolve, reject) => { |
| | | //å è½½æ°æ® è¥ä¼ å
¥åæ°1åå 载第ä¸é¡µçå
容 |
| | | if (arg === 1) { |
| | | this.pagination.current = 1 |
| | | } |
| | | var params = Object.assign({}, this.queryParam, { |
| | | pageNo: this.pagination.current, |
| | | pageSize: this.pagination.pageSize |
| | | }) |
| | | console.log('params', params) |
| | | if (!params) { |
| | | reject(new Error('æ¥è¯¢åæ°æ æ')) |
| | | return false |
| | | } |
| | | this.loading = true |
| | | getAction(this.url.list, params).then((res) => { |
| | | if (res.success) { |
| | | this.dataSource = res.result.records || res.result |
| | | if (res.result.total) { |
| | | this.pagination.total = res.result.total |
| | | } else { |
| | | this.pagination.total = 0 |
| | | } |
| | | resolve(res) |
| | | } else { |
| | | this.$message.warning(res.message) |
| | | reject(new Error(res.message)) |
| | | } |
| | | }).catch(error => { |
| | | reject(error) |
| | | }).finally(() => { |
| | | this.loading = false |
| | | }) |
| | | }) |
| | | }, |
| | | handlePageChange({ currentPage, pageSize }) { |
| | | this.pagination.current = currentPage |
| | | this.pagination.pageSize = pageSize |
| | | this.loadData() |
| | | }, |
| | | searchQuery() { |
| | | if (!this.queryParam.factoryId || this.dateRange.length === 0) { |
| | | this.$message.warning('è¯·éæ©äº§çº¿åæäº§æ¥æèå´ï¼') |
| | | return |
| | | } |
| | | this.queryParam = Object.assign(this.queryParam, this.dateRange) |
| | | this.loadData(1).then(() => { |
| | | this.initTableData(null, this.dateRange) |
| | | // 设置æ¥åæ¾ç¤ºä¸ºæ¥è¯¢æ¥æèå´å
ç第ä¸å¨ |
| | | if (this.dateRange[0]) { |
| | | this.calendarStartDate = this.dateRange[0].clone().startOf('week'); |
| | | } |
| | | }) |
| | | }, |
| | | searchReset() { |
| | | this.queryParam = {} |
| | | this.dateRange = [] |
| | | this.workOrdersByDate = {} |
| | | this.dataSource = [] |
| | | this.pagination.total = 0 |
| | | }, |
| | | // çæå·¥åå·çæ¹æ³ |
| | | generateWorkOrderCode(row) { |
| | | // è·ååä¸ªåæ®µçå¼ |
| | | const factoryCode = row.factoryCode || ''; |
| | | const materialNumber = row.materialNumber || ''; |
| | | const workDate = row.workOrderDate || ''; |
| | | const shiftCode = row.shiftCode || ''; |
| | | |
| | | let formattedDate = workDate; |
| | | if (workDate && workDate.length >= 10) { |
| | | // 妿æ¯å®æ´æ¥ææ ¼å¼ï¼æå YYYY-MM-DD é¨å |
| | | formattedDate = workDate.substring(0, 10).replace(/-/g, ''); |
| | | } |
| | | return `${factoryCode}${materialNumber}${formattedDate}${shiftCode}`; |
| | | }, |
| | | updateWorkOrderCode(row) { |
| | | row.workOrderCode = this.generateWorkOrderCode(row); |
| | | }, |
| | | // æ ¼å¼åæ¥æä¸º YYYY-MM-DD |
| | | formatDate(date) { |
| | | const year = date.getFullYear(); |
| | | const month = String(date.getMonth() + 1).padStart(2, '0'); |
| | | const day = String(date.getDate()).padStart(2, '0'); |
| | | return `${year}-${month}-${day}`; |
| | | }, |
| | | // çææ¥æèå´æ°ç» |
| | | generateDateRangeOptions(startDate, endDate) { |
| | | const dateOptions = []; |
| | | const start = new Date(startDate); |
| | | const end = new Date(endDate); |
| | | |
| | | // 设置æ¶é´ä¸ºæ¯å¤©ç0ç¹ |
| | | start.setHours(0, 0, 0, 0); |
| | | end.setHours(0, 0, 0, 0); |
| | | |
| | | // çææ¥æèå´å
çæææ¥æ |
| | | for (let date = new Date(start); date <= end; date.setDate(date.getDate() + 1)) { |
| | | const formattedDate = this.formatDate(date); |
| | | dateOptions.push({ |
| | | value: formattedDate, |
| | | label: formattedDate |
| | | }); |
| | | } |
| | | return dateOptions; |
| | | }, |
| | | initDictSelectOptions(record) { |
| | | return new Promise((resolve) => { |
| | | // å¹¶è¡æ§è¡å¤ä¸ªå¼æ¥è¯·æ± |
| | | const promises = []; |
| | | |
| | | let factoryId |
| | | if (record && record.length > 0) { |
| | | factoryId = record[0].factoryId |
| | | } else { |
| | | factoryId = this.queryParam.factoryId |
| | | } |
| | | |
| | | const shiftGroupPromise = getAction(this.url.queryShiftGroupByFactoryId, { factoryId: factoryId }).then(res => { |
| | | if (res.success) { |
| | | this.shiftOptions = res.result.map(item => { |
| | | return { |
| | | value: item.shiftId, |
| | | label: item.shiftId_dictText |
| | | } |
| | | }) |
| | | this.groupShiftMap = res.result.reduce((map, item) => { |
| | | map[item.shiftId] = { |
| | | groupId: item.id, |
| | | shiftCode: item.shiftCode_dictText, |
| | | shiftName: item.shiftId_dictText |
| | | } |
| | | return map |
| | | }, {}) |
| | | } |
| | | }).catch(() => { |
| | | }); |
| | | promises.push(shiftGroupPromise); |
| | | |
| | | const materialNumberPromise = ajaxGetDictItems("lsw_material,material_name,material_number,del_flag!='1' order by material_number asc", null).then(res => { |
| | | if (res.success) { |
| | | this.materialOptions = res.result.map(item => { |
| | | return { |
| | | value: item.value, |
| | | label: item.value |
| | | } |
| | | }); |
| | | this.materNumberNameMap = res.result.reduce((map, item) => { |
| | | map[item.value] = item.text |
| | | return map |
| | | }, {}) |
| | | } |
| | | }).catch(() => { |
| | | }); |
| | | promises.push(materialNumberPromise); |
| | | |
| | | // çå¾
ææè¯·æ±å®æ |
| | | Promise.all(promises).then(() => { |
| | | resolve(); |
| | | }); |
| | | }) |
| | | }, |
| | | generatePlan() { |
| | | if (!this.queryParam.factoryId || this.dateRange.length === 0) { |
| | | this.$message.warning('è¯·éæ©äº§çº¿åæäº§æ¥æèå´ï¼') |
| | | return |
| | | } |
| | | getAction(this.url.schedule, { |
| | | factoryId: this.queryParam.factoryId, |
| | | startDate: this.dateRange[0].format('YYYY-MM-DD'), |
| | | endDate: this.dateRange[1].format('YYYY-MM-DD') |
| | | }).then(res => { |
| | | if (res.success) { |
| | | const record = res.result |
| | | this.initTableData(record, this.dateRange) |
| | | // 设置æ¥åæ¾ç¤ºä¸ºçæè®¡åæ¥æèå´å
ç第ä¸å¨ |
| | | if (this.dateRange[0]) { |
| | | this.calendarStartDate = this.dateRange[0].clone().startOf('week'); |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | initTableData(record, dateRange) { |
| | | // å
å è½½åå
¸æ°æ®ï¼ååå§å表å |
| | | this.initDictSelectOptions(record).then(() => { |
| | | this.$nextTick(() => { |
| | | // æ ¹æ®æ¥æèå´çææäº§æ¥æé项 |
| | | if (dateRange && dateRange.length === 2) { |
| | | this.workOrderDateOptions = this.generateDateRangeOptions(dateRange[0], dateRange[1]); |
| | | } |
| | | |
| | | // ä¸ºæ¯æ¡è®°å½çæå·¥åå· |
| | | if (record && record.length > 0) { |
| | | record.forEach(row => { |
| | | if (!row.workOrderCode) { |
| | | this.updateWorkOrderCode(row); |
| | | } |
| | | }); |
| | | this.dataSource.push(...record) |
| | | } |
| | | this.pagination.total = this.dataSource.length |
| | | this.$nextTick(() => { |
| | | if (this.$refs.table && this.dataSource.length > 0) { |
| | | // æ¿æ´»ç¬¬ä¸è¡è¿å
¥ç¼è¾ç¶æ |
| | | this.$refs.table.setActiveRow(this.dataSource[0]) |
| | | } |
| | | }) |
| | | }); |
| | | }) |
| | | }, |
| | | handleWorkOrderDateChange($event, value) { |
| | | $event.row.workOrderDate = value.value; |
| | | this.updateWorkOrderCode($event.row) |
| | | }, |
| | | handleMaterialChange($event, value) { |
| | | const key = value.value |
| | | if (key && this.materNumberNameMap[key]) { |
| | | $event.row.materialName = this.materNumberNameMap[key] |
| | | } else { |
| | | $event.row.materialName = ''; |
| | | } |
| | | // æ´æ°ç©æç¼å· |
| | | $event.row.materialNumber = key; |
| | | // éæ°çæå·¥åå· |
| | | this.updateWorkOrderCode($event.row); |
| | | }, |
| | | handleShiftChange($event, value) { |
| | | const key = value.value |
| | | // ä» groupShiftMap ä¸è·å对åºççç»id |
| | | if (key && this.groupShiftMap[key]) { |
| | | // æ´æ°å½åè¡ççç»idãçæ¬¡ç¼ç ï¼æ¼æ¥å·¥åå·ç¨ï¼å段 |
| | | $event.row.groupId = this.groupShiftMap[key].groupId |
| | | $event.row.shiftCode = this.groupShiftMap[key].shiftCode |
| | | $event.row.shiftName = this.groupShiftMap[key].shiftName |
| | | } else { |
| | | // å¦ææ²¡æå¹é
ççç»ï¼åæ¸
空 |
| | | $event.row.groupId = '' |
| | | $event.row.shiftCode = '' |
| | | $event.row.shiftName = '' |
| | | } |
| | | // éæ°çæå·¥åå· |
| | | this.updateWorkOrderCode($event.row); |
| | | }, |
| | | async addSchedulePlan() { |
| | | if (!this.queryParam.factoryId || this.dateRange.length === 0) { |
| | | this.$message.warning('请å
éæ©äº§çº¿åæäº§æ¥æèå´ï¼') |
| | | return |
| | | } |
| | | let factoryCode = '' |
| | | if (this.dataSource.length === 0) { |
| | | const res = await getAction(this.url.queryFactoryById, {id: this.queryParam.factoryId}) |
| | | if (res.success) { |
| | | factoryCode = res.result.factoryCode |
| | | } |
| | | } else { |
| | | factoryCode = this.dataSource[0].factoryCode |
| | | } |
| | | // å建æ°è¡æ°æ® |
| | | const newRow = { |
| | | workOrderCode: factoryCode, |
| | | materialNumber: '', |
| | | materialName: '', |
| | | factoryId: this.dataSource.length > 0 ? this.dataSource[0].factoryId : this.queryParam.factoryId, |
| | | factoryCode: factoryCode, |
| | | groupId: '', |
| | | shiftId: '', |
| | | shiftCode: '', |
| | | shiftName: '', |
| | | workOrderDate: '', |
| | | planQuantity: '' |
| | | } |
| | | this.initDictSelectOptions(null).then(() => { |
| | | // æ ¹æ®æ¥æèå´çææäº§æ¥æé项 |
| | | if (this.dateRange && this.dateRange.length === 2) { |
| | | this.workOrderDateOptions = this.generateDateRangeOptions(this.dateRange[0], this.dateRange[1]); |
| | | } |
| | | this.dataSource.push(newRow) |
| | | this.pagination.total += 1 |
| | | // æ¿æ´»æ°å¢çè¡è¿å
¥ç¼è¾ç¶æ |
| | | this.$nextTick(() => { |
| | | if (this.$refs.table) { |
| | | this.$refs.table.setActiveRow(newRow) |
| | | } |
| | | }) |
| | | }) |
| | | }, |
| | | handleRemove(row) { |
| | | let table = this.$refs.table |
| | | this.$confirm({ |
| | | title: 'æç¤º', |
| | | content: '确认è¦å é¤åï¼', |
| | | okText: 'ç¡®å®', |
| | | cancelText: 'åæ¶', |
| | | onOk: () => { |
| | | const index = this.dataSource.indexOf(row) |
| | | if (index > -1) { |
| | | this.dataSource.splice(index, 1) |
| | | this.pagination.total -= 1 |
| | | } |
| | | // å é¤è¡ |
| | | table.remove(row) |
| | | } |
| | | }) |
| | | }, |
| | | onOpenChange(open) { |
| | | if (!open) { |
| | | // å
³é鿩卿¶éç½®ç¶æ |
| | | this.tempStartDate = null |
| | | this.hoveredDate = null |
| | | } |
| | | }, |
| | | disabledDate(current) { |
| | | // 妿æä¸´æ¶å¼å§æ¥æï¼åéå¶ç»ææ¥æèå´ |
| | | if (this.tempStartDate) { |
| | | const startDate = this.tempStartDate.clone().startOf('day') |
| | | const maxDate = startDate.clone().add(6, 'days').endOf('day') // 7天å
æ¬èµ·å§æ¥ |
| | | const minDate = startDate.clone().subtract(6, 'days').startOf('day') // ä¹å¯ä»¥ååé6天 |
| | | // ç¦ç¨è¶
åº7天èå´çæ¥æ |
| | | return current && (current < minDate || current > maxDate) |
| | | } |
| | | // é»è®¤ä¸ç¦ç¨ |
| | | return false |
| | | }, |
| | | dateRangeChange(dates, dateStrings) { |
| | | this.dateRange = dates |
| | | if (dates && dates.length > 0) { |
| | | if (dates.length === 1) { |
| | | // éæ©äºå¼å§æ¥æï¼ä¿åå°ä¸´æ¶åé |
| | | this.tempStartDate = dates[0] |
| | | this.hoveredDate = dates[0] |
| | | } else if (dates.length === 2) { |
| | | // éæ©äºç»ææ¥æï¼éªè¯èå´ |
| | | const startDate = dates[0] |
| | | const endDate = dates[1] |
| | | const diffDays = endDate.diff(startDate, 'days') + 1 |
| | | |
| | | if (diffDays > 7) { |
| | | this.$message.warning('æ¥æèå´ä¸è½è¶
è¿7天') |
| | | // èªå¨è°æ´ä¸º7天èå´ |
| | | const adjustedEndDate = startDate.clone().add(6, 'days') |
| | | this.dateRange = [startDate, adjustedEndDate] |
| | | this.queryParam.startDate = startDate.format('YYYY-MM-DD') |
| | | this.queryParam.endDate = adjustedEndDate.format('YYYY-MM-DD') |
| | | } else { |
| | | this.queryParam.startDate = dateStrings[0] |
| | | this.queryParam.endDate = dateStrings[1] |
| | | } |
| | | // é置临æ¶ç¶æ |
| | | this.tempStartDate = null |
| | | this.hoveredDate = null |
| | | } |
| | | |
| | | // æ´æ°æ¥åæ¾ç¤ºä¸ºé䏿¥ææå¨å¨ |
| | | if (dates[0]) { |
| | | this.calendarStartDate = dates[0].clone().startOf('week'); |
| | | } |
| | | } else { |
| | | // æ¸
é¤äºéæ© |
| | | this.queryParam.startDate = null |
| | | this.queryParam.endDate = null |
| | | this.tempStartDate = null |
| | | this.hoveredDate = null |
| | | // éç½®æ¥å为å½åå¨ |
| | | this.calendarStartDate = moment().startOf('week'); |
| | | } |
| | | }, |
| | | // å¤çæ¥æéæ©äºä»¶ - æ´æ°æ¥åæ¾ç¤ºä¸ºé䏿¥ææå¨å¨ |
| | | onDateSelect(date) { |
| | | console.log('Selected date:', date.format('YYYY-MM-DD')) |
| | | // æ´æ°æ¥åæ¾ç¤ºä¸ºé䏿¥ææå¨å¨ |
| | | this.calendarStartDate = date.clone().startOf('week'); |
| | | }, |
| | | |
| | | // å¤çæ¥åå¨ååäºä»¶ |
| | | onCalendarChange(date) { |
| | | console.log('Calendar week changed:', date.format('YYYY-MM-DD')) |
| | | // æ¥åå¨ååæ¶æ´æ° startDate |
| | | this.calendarStartDate = date.clone().startOf('week'); |
| | | }, |
| | | // æ´æ°æ¥åä¸çå·¥åæ°æ® |
| | | updateCalendarWorkOrders() { |
| | | const workOrdersByDate = {} |
| | | this.dataSource.forEach(workOrder => { |
| | | const workOrderDate = workOrder.workOrderDate |
| | | if (workOrderDate) { |
| | | if (!workOrdersByDate[workOrderDate]) { |
| | | workOrdersByDate[workOrderDate] = [] |
| | | } |
| | | workOrdersByDate[workOrderDate].push({ |
| | | id: workOrder.id, |
| | | shiftCode: workOrder.shiftCode || '', |
| | | materialName: workOrder.materialName || '', |
| | | planQuantity: workOrder.planQuantity || 0 |
| | | }) |
| | | } |
| | | }) |
| | | this.workOrdersByDate = workOrdersByDate |
| | | }, |
| | | // è·åæå®æ¥æçå·¥å |
| | | getWorkOrdersForDate(date) { |
| | | const dateStr = date.format('YYYY-MM-DD') |
| | | return this.workOrdersByDate[dateStr] || [] |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style scoped> |
| | | @import '~@assets/less/common.less'; |
| | | |
| | | .placeholder-text { |
| | | font-style: italic; |
| | | color: #999; |
| | | } |
| | | |
| | | .work-order-item { |
| | | font-size: 12px; |
| | | padding: 2px 4px; |
| | | margin-bottom: 2px; |
| | | background-color: #f0f0f0; |
| | | border-radius: 2px; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | } |
| | | |
| | | .work-order-item.blue-item { |
| | | background-color: #e6f7ff; |
| | | border-left: 2px solid #1890ff; |
| | | } |
| | | |
| | | .work-order-item.red-item { |
| | | background-color: #fff1f0; |
| | | border-left: 2px solid #f5222d; |
| | | } |
| | | |
| | | .work-order-shift { |
| | | font-weight: bold; |
| | | margin-right: 4px; |
| | | } |
| | | |
| | | .work-order-material { |
| | | margin-right: 4px; |
| | | } |
| | | |
| | | .work-order-quantity { |
| | | float: right; |
| | | } |
| | | </style> |