| | |
| | | <!-- |
| | | * @Date: 2024-04-04 22:45:43 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-11 15:26:41 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/base/CalenderTab.vue |
| | | * @LastEditors: gaosp |
| | | * @LastEditTime: 2024-09-07 15:15:29 |
| | | * @FilePath: /mdc/Users/mache/Documents/demo/cps-web/src/views/console/base/CalenderTab.vue |
| | | --> |
| | | <template> |
| | | <el-container> |
| | | <el-aside width="220px"> |
| | | <el-button type="primary" icon="el-icon-plus" @click="add">新建日历</el-button> |
| | | <div v-infinite-scroll="load"> |
| | | <el-card shadow="never" class="card" v-for="item in caleList" :key="item.id" @click="select(item)"> |
| | | <el-card shadow="never" class="card" :class="selectInfo.id === item.id ? 'active' : ''" |
| | | v-for="item in caleList" :key="item.id" @click="select(item)"> |
| | | <h3>{{ item.code }}</h3> |
| | | <p>日历名称: {{ item.name }}</p> |
| | | <p>应用年份: {{ item.year }}</p> |
| | |
| | | <el-container> |
| | | <el-header> |
| | | <span>日历【{{ selectInfo.code }}】{{ selectInfo.name }}</span> |
| | | <el-button type="primary" style="margin-left: auto;" size="small">关联工位</el-button> |
| | | <el-button type="primary" style="margin-left: auto;" size="small" @click="relationWork">关联工位</el-button> |
| | | <!-- <el-button type="primary" size="small">编辑日历</el-button> --> |
| | | <el-popconfirm title="确定删除吗?" @confirm="table_del"> |
| | | <template #reference> |
| | |
| | | </el-container> |
| | | <el-drawer v-model="drawer" size="80%" title="生产日历" :direction="direction" :before-close="handleClose"> |
| | | <Add :shiftList="shiftList" @success="success"></Add> |
| | | </el-drawer> |
| | | <el-drawer v-model="raworkVisible" size="80%" title="生产日历" :direction="direction" :before-close="handleClose"> |
| | | <el-container v-if="raworkVisible"> |
| | | <el-main> |
| | | <el-tree ref="workstations" default-expand-all :data="workStations" show-checkbox node-key="id" |
| | | :props="defaultProps" :render-content="renderContent" /> |
| | | </el-main> |
| | | <el-footer style="text-align: right"> |
| | | <el-button type="primary" @click="saveBefore">保存</el-button> |
| | | </el-footer> |
| | | </el-container> |
| | | |
| | | </el-drawer> |
| | | </el-container> |
| | | </template> |
| | |
| | | total: 1, |
| | | caleList: [], |
| | | minDate: '', |
| | | maxDate: '' |
| | | maxDate: '', |
| | | raworkVisible: false, |
| | | defaultProps: { |
| | | label: 'title', |
| | | children: 'children', |
| | | }, |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | relationWork() { |
| | | this.$HTTP.post('/api/blade-cps/group/groupWorkstation', { groupCategory: 1, groupType: 'group_workstation' }).then(res => { |
| | | if (res.code === 200) { |
| | | this.raworkVisible = true |
| | | this.workStations = this.formatData(res.data) |
| | | console.log(this.workStations) |
| | | } |
| | | }) |
| | | |
| | | }, |
| | | formatData(data, current) { |
| | | let newData = [] |
| | | if (!current) { |
| | | newData = data.filter(item => item.parentId == 0).map(v => { |
| | | v.children = this.formatData(data, v).sort((a, b) => { |
| | | return b.sort - a.sort |
| | | }) |
| | | return v |
| | | }) |
| | | } else { |
| | | let res = data.filter(v => v.parentId == current.id) |
| | | res = res.map(item => { |
| | | item.children = this.formatData(data, item).sort((a, b) => { |
| | | return b.sort - a.sort |
| | | }) |
| | | return item |
| | | }) |
| | | return res |
| | | } |
| | | return newData |
| | | }, |
| | | renderContent(h, { data }) { |
| | | if (data.isWorkstation) { |
| | | return h('div', {}, [ |
| | | h('span', {}, data.title), |
| | | data.calendarCode ? h('span', { |
| | | style: { |
| | | marginLeft: '10px', |
| | | color: 'var(--el-color-primary)' |
| | | } |
| | | }, `已关联(${data.calendarCode})`) : '' |
| | | ]) |
| | | } else { |
| | | return data.title |
| | | } |
| | | }, |
| | | saveBefore() { |
| | | let workstation = this.$refs.workstations.getCheckedNodes().filter(v => v.isWorkstation) || [] |
| | | if (workstation.length == 0) { |
| | | return this.$message.warning("请选择"); |
| | | } |
| | | if (workstation.some(v => v.calendarCode).length > 0) { |
| | | this.$confirm(`所选工位已有排班,确认要重新关联生产日历吗?`, '提示', { |
| | | type: 'warning', |
| | | }).then(() => { |
| | | this.save(workstation.map(v => v.id)) |
| | | }).catch(() => { |
| | | return false |
| | | }) |
| | | } else { |
| | | this.save(workstation.map(v => v.id)) |
| | | } |
| | | console.log(this.$refs.workstations.getCheckedNodes().filter(v => v.isWorkstation)) |
| | | }, |
| | | save(workstationIdList) { |
| | | console.log(workstationIdList, this.selectInfo) |
| | | this.$HTTP.post('/api/blade-cps/calendar/associate-workstation', { |
| | | calendarCode: this.selectInfo.code, |
| | | workstationIdList |
| | | }).then(res => { |
| | | if (res.code === 200) { |
| | | this.$message.success("操作成功"); |
| | | this.raworkVisible = false |
| | | } else { |
| | | this.$message.error(res.msg); |
| | | } |
| | | }) |
| | | }, |
| | | dayclick(day) { |
| | | console.log(day) |
| | | }, |
| | |
| | | margin: 12px 12px 12px 0; |
| | | } |
| | | |
| | | .card.active { |
| | | border: 1px solid var(--el-color-primary); |
| | | } |
| | | |
| | | .vc-arrow { |
| | | display: none !important; |
| | | } |