lius
2023-06-08 c66a22e4b6bb02667a5000f2e04aeb4ef5ae44c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
  <a-card :bordered="false" class="shift_info">
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" v-if="Object.keys(shiftSystemRow).length>0" @click="handleAdd" icon="plus">配置</a-button>
    </div>
    <!-- table区域-begin -->
    <div style="width: 100%;">
      <a-table ref="table" bordered size="middle" rowKey="id" :columns="columns"
               :dataSource="dataSource" :pagination="false" :loading="loading">
         <span
           slot="shiftSubStatus"
           slot-scope="text, record"
         >
           <span v-if="text == 0" style="color:red;">停用</span>
           <span v-if="text == 1" style="color:green;">启用</span>
         </span>
        <span
          slot="isDaySpan"
          slot-scope="text, record"
        >
           <span v-if="text == 'true'">是</span>
           <span v-if="text == 'false'">否</span>
         </span>
        <span
          slot="action"
          slot-scope="text, record"
        >
          <a-dropdown>
            <a class="ant-dropdown-link">
              <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="record.shiftSubStatus == 1">
                <a key="1" @click="handleEdit(record)">编辑</a>
              </a-menu-item>
              <a-menu-item v-if="record.shiftSubStatus == 0">
                <a key="2" @click="handleStatus(record.id,1)">启用</a>
              </a-menu-item>
              <a-menu-item v-if="record.shiftSubStatus == 1">
                <a key="3" @click="handleStatus(record.id,0)">停用</a>
              </a-menu-item>
               <a-menu-item >
                <a key="4" @click="handleDelete(record.id)">删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
 
    <shift-info-model ref="modalForm" @ok="modalFormOk"></shift-info-model>
  </a-card>
</template>
 
<script>
  import {
    requestPut, putAction, deleteAction
  } from '@/api/manage'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import ShiftInfoModel from './ShiftInfoModel'
 
  export default {
    name: 'ShiftInfo',
    mixins: [JeecgListMixin],
    components: {
      ShiftInfoModel
    },
    props: {
      shiftSystemRow: {
        type: Object,
        required: true,
        default: {}
      }
    },
    data() {
      return {
        statusName: '',
        disabled: true,
        disableMixinCreated: true,
        url: {
          list: '/mdc/mdcShiftSub/queryPageList',
          changeStatus: '/mdc/mdcShiftSub/updateSubStatusById',
          deleteBatch: '/mdc/mdcShiftSub/deleteMdcShiftSub'
        },
        columns: [
          {
            title: '班次',
            align: 'center',
            dataIndex: 'shiftSubName'
          },
          {
            title: '开始时间',
            align: 'center',
            dataIndex: 'startDate'
          },
          {
            title: '结束时间',
            align: 'center',
            dataIndex: 'endDate'
          },
          {
            title: '是否跨天',
            align: 'center',
            dataIndex: 'isDaySpan',
            scopedSlots: { customRender: 'isDaySpan' }
          },
          {
            title: '开始休息时间',
            align: 'center',
            dataIndex: 'sleepStartDate'
          },
          {
            title: '结束休息时间',
            align: 'center',
            dataIndex: 'sleepEndDate'
          },
          {
            title: '状态',
            align: 'center',
            dataIndex: 'shiftSubStatus',
            scopedSlots: { customRender: 'shiftSubStatus' }
          },
          {
            title: '操作',
            align: 'center',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ]
      }
    },
    methods: {
      handleAdd() {
        this.$refs.modalForm.add(this.shiftSystemRow)
        this.$refs.modalForm.title = '班次配置'
        this.$refs.modalForm.disableSubmit = false
      },
      handleEdit(record) {
        record.shiftId = this.shiftSystemRow.id
        record.shiftName = this.shiftSystemRow.shiftName
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '班次配置'
        this.$refs.modalForm.disableSubmit = true
      },
      handleDelete: function(record){
        if(!this.url.deleteBatch){
          this.$message.error("请设置url.delete属性!")
          return
        }
        var that = this;
        deleteAction(that.url.deleteBatch, {id: record}).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            that.loadData();
          } else {
            that.$message.warning(res.message);
          }
        });
      },
      handleStatus(id, status) {
        let _this = this
        putAction(this.url.changeStatus, { id: id, status: status }).then((res) => {
          if (res.success) {
            _this.$message.success('操作成功!')
            _this.loadData()
          } else {
            that.$message.warning('操作失败!')
          }
        })
      },
    },
    created() {
    },
    watch: {
      shiftSystemRow(val) { // 监听currSelected 变化,将变化后的数值传递给 getCurrSelected 事件
        this.queryParam.shiftId = val.id
        this.loadData()
      }
    }
 
  }
</script>
 
<style lang="less" scoped>
  @media screen and (min-width: 1920px){
    .shift_info{
      height: 748px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1680px) and (max-width: 1920px){
    .shift_info{
      height: 748px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1400px) and (max-width: 1680px){
    .shift_info{
      height: 600px!important;
      overflow: scroll;
    }
  }
  @media screen and (min-width: 1280px) and (max-width: 1400px){
    .shift_info{
      height: 501px!important;
      overflow: scroll;
    }
  }
  @media screen and (max-width: 1280px){
    .shift_info{
      height: 501px!important;
      overflow: scroll;
    }
  }
</style>