| | |
| | | <!-- |
| | | * @Date: 2024-04-09 20:19:46 |
| | | * @LastEditors: Sneed |
| | | * @LastEditTime: 2024-04-09 21:57:50 |
| | | * @LastEditTime: 2024-04-28 23:55:44 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/base/Shiftsystem.vue |
| | | --> |
| | | <template> |
| | | <el-container> |
| | | <el-aside width="320px"> |
| | | <el-button type="primary" @click="add">新建班制</el-button> |
| | | <el-table :data="tableData" stripe style="width: 100%" @row-click="rowClick"> |
| | | <el-table-column prop="code" label="班制编号" /> |
| | | <scTable style="width: 100%;" ref="table" row-key="id" border :params="params" :apiObj="apiObj" stripe |
| | | :hideDo="true" paginationLayout="total, prev, pager, next" @dataChange="dataChange" |
| | | @row-click="rowClick" highlight-current-row> |
| | | <el-table-column prop="code" label="班制编号" width="100px" /> |
| | | <el-table-column prop="name" label="班制名称" /> |
| | | </el-table> |
| | | </scTable> |
| | | </el-aside> |
| | | <el-container> |
| | | <ul> |
| | | <li> |
| | | <span>班制编号</span> |
| | | {{ info.code }} |
| | | </li> |
| | | <li> |
| | | <span>班制颜色</span> |
| | | {{ info.code }} |
| | | </li> |
| | | <li> |
| | | <span>开始-结束时间</span> |
| | | {{ info.code }} |
| | | </li> |
| | | </ul> |
| | | <el-header> |
| | | <el-button style="margin-left: auto;" size="small" @click="table_add" type="primary" |
| | | icon="el-icon-plus"></el-button> |
| | | <el-button @click="table_edit" type="primary" size="small">编辑</el-button> |
| | | <el-button type="danger" plain icon="el-icon-delete" size="small" @click="del"></el-button> |
| | | </el-header> |
| | | <el-main> |
| | | <el-row> |
| | | <el-col :span="2"> |
| | | 班制编号 |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | {{ info.code }} |
| | | </el-col> |
| | | <el-col :span="2"> |
| | | 班制颜色 |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-color-picker size="small" v-model="info.colour" /> |
| | | </el-col> |
| | | <el-col :span="2"> |
| | | 开始-结束时间 |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | {{ dateFormat(info.startTime) }} - {{ dateFormat(info.endTime | dateFormat) }} |
| | | </el-col> |
| | | </el-row> |
| | | <el-row style="margin-top: 20px;"> |
| | | <el-timeline style="max-width: 600px"> |
| | | <el-timeline-item v-for="(activity, index) in activities" :key="index" |
| | | :timestamp="activity.time"> |
| | | {{ activity.title }} |
| | | </el-timeline-item> |
| | | </el-timeline> |
| | | </el-row> |
| | | <el-row> |
| | | |
| | | </el-row> |
| | | </el-main> |
| | | </el-container> |
| | | <Dialog ref="dialog" :option="{types,status,group}"></Dialog> |
| | | <Dialog ref="dialog" :option="{ types, status, group }"></Dialog> |
| | | </el-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import Dialog from './Dialog.vue' |
| | | import moment from 'moment'; |
| | | export default { |
| | | components: { |
| | | Dialog |
| | | }, |
| | | data () { |
| | | return { |
| | | tableData: [], |
| | | info: { |
| | | code: '' |
| | | computed: { |
| | | dateFormat: () => { |
| | | return value => { |
| | | if (isNaN(value)) return '' |
| | | let pre = '当日' |
| | | let add = value / (24 * 60) |
| | | if (add < 0) { |
| | | pre = '上日' |
| | | } else if (add >= 1) { |
| | | pre = '次日' |
| | | } |
| | | let base = moment().format('YYYY-MM-DD') + ' 00:00' |
| | | let current = moment(base).add(value, 'm') |
| | | return pre + moment(current).format('HH:mm'); |
| | | } |
| | | }, |
| | | activities() { |
| | | if (!this.info?.shiftDetailVOList?.length) return [] |
| | | return this.info.shiftDetailVOList.map(item => { |
| | | return { |
| | | title: `班次名称:${item.indexName}`, |
| | | time: `${this.dateFormat(item.shiftStartTime)}-${this.dateFormat(item.shiftEndTime)}` |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | created () { |
| | | this.$API.calender.getShiftsystemList.post({params: {current:1,size: 15},data: { |
| | | code: "",name: "",statusList: [1] |
| | | }}).then(res => { |
| | | this.tableData = res?.data?.records || [] |
| | | let current = this.tableData?.[0] || '' |
| | | current.id && this.rowClick(current) |
| | | }) |
| | | data() { |
| | | return { |
| | | apiObj: this.$API.calender.getShiftsystemList, |
| | | params: { |
| | | statusList: [1], |
| | | code: '', |
| | | name: '' |
| | | }, |
| | | info: { |
| | | code: '' |
| | | }, |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | methods: { |
| | | dataChange(res, tableData) { |
| | | let current = tableData?.[0] || {} |
| | | current.id && this.rowClick(current) |
| | | }, |
| | | rowClick(row) { |
| | | console.log(row) |
| | | this.$API.calender.getShiftsystemInfo.get({id: row.id}).then(res => { |
| | | console.log(res.data) |
| | | this.$API.calender.getShiftsystemInfo.get({ id: row.id }).then(res => { |
| | | this.info = res.data |
| | | }) |
| | | }, |
| | | add () { |
| | | table_add() { |
| | | this.$refs.dialog.open() |
| | | }, |
| | | table_edit() { |
| | | this.$refs.dialog.open() |
| | | }, |
| | | del() { |
| | | |
| | | } |
| | | }, |
| | | } |