vue2-client 1.15.106 → 1.15.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114001.vue +342 -0
  2. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114005.vue +342 -0
  3. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114014.vue +345 -0
  4. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114020.vue +345 -0
  5. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114028.vue +345 -0
  6. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114108.vue +345 -0
  7. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114115.vue +345 -0
  8. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114333.vue +346 -0
  9. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114339.vue +350 -0
  10. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114344.vue +355 -0
  11. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114351.vue +355 -0
  12. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114408.vue +355 -0
  13. package/.history/src/base-client/components/his/XShiftSchedule/XShiftSchedule_20250811114410.vue +355 -0
  14. package/package.json +1 -1
  15. package/src/base-client/components/common/XForm/XFormItem.vue +8 -26
  16. package/src/base-client/components/his/XImportExcelButton/XFrontImportExcelDemo.vue +3 -1
  17. package/src/base-client/components/his/XShiftSchedule/XShiftSchedule.vue +39 -26
  18. package/src/utils/routerUtil.js +7 -0
@@ -0,0 +1,350 @@
1
+ <template>
2
+ <div v-if="pattern == 'schedule'">
3
+ <a-table
4
+ :columns="columns"
5
+ :data-source="data"
6
+ :rowSelection="rowSelection"
7
+ :scroll="{ y: configData.height == null? '70%' : configData.height }">
8
+ <span slot="time" class="time-title">
9
+ <span v-for="(item, index) in configData.timePeriod" :key="index">{{ item }}</span>
10
+ </span>
11
+ <div v-for="(item, index) in weekDays" :key="index" :slot="item.key" class="week_last_next_btn">
12
+ <a-button slot="lastWeek" icon="left" size="large" @click="handleLastWeek" v-if="item.title == '周一'" />
13
+ <div class="time-title">
14
+ <span>{{ item.title }}</span>
15
+ <span>{{ currentWeekDates[index].toLocaleDateString() }}</span>
16
+ </div>
17
+ <a-button slot="nextWeek" icon="right" size="large" @click="handleNextWeek" v-if="item.title == '周日'"/>
18
+ </div>
19
+ <template :slot="day.key" slot-scope="text, record" v-for="day in shiftTable">
20
+ <div class="time-title" :key="day.key">
21
+ <a-button v-for="(item, index) in record[day.key]" :key="index" @click="handleShiftChange(day.key, index, record)">{{ item === 1 || item === '1' ? '坐诊' : '休息' }}</a-button>
22
+ </div>
23
+ </template>
24
+ <template slot="sk_limit" slot-scope="text, record">
25
+ <a-input-number id="inputNumber" v-model="record.sk_limit" :min="configData.sk_limitMin" :max="configData.sk_limitMax" />
26
+ </template>
27
+ </a-table>
28
+ </div>
29
+ <div v-else-if="pattern == 'form'">
30
+ <a-table :columns="columns" :data-source='data' :row-selection="rowSelection" bordered :scroll="{ y: configData.height == null? '70%' : configData.height }">
31
+ <template v-for="(n, i) in inputColumns" :slot="n.dataIndex" slot-scope="text, record">
32
+ <div class="a-div" :key="i">
33
+ <a-input
34
+ v-for="(item, index) in n.row"
35
+ :key="index"
36
+ placeholder=""
37
+ class="ant-input"
38
+ v-model="record[n.dataIndex][index + 1]"
39
+ @input="handleInputChange(record, n.dataIndex, index + 1, $event.target.value)"
40
+ :disabled="!isRowSelected(record.key)"
41
+ />
42
+ </div>
43
+ </template>
44
+ <div class="a-div" v-for="(n, i) in numberColumns" :slot="n.dataIndex" :key="i">
45
+ <div v-for="(item, index) in n.row" :key="index" class="number">{{item}}</div>
46
+ </div>
47
+ </a-table>
48
+ </div>
49
+ </template>
50
+ <script>
51
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
52
+
53
+ export default {
54
+ data () {
55
+ return {
56
+ // 高度
57
+ height: '70%',
58
+ // 输入框数据
59
+ inputData: [],
60
+ // 模式
61
+ pattern: 'schedule',
62
+ data: [],
63
+ // 列配置
64
+ columns: [],
65
+ // 列名
66
+ columnNames: [],
67
+ // 选中的行键值集合
68
+ selectedRows: [],
69
+ // 选中的行信息集合
70
+ selectedRowKeys: [],
71
+ // 原始数据备份
72
+ originalData: [],
73
+ // 配置参数
74
+ configData: {},
75
+ // 当前显示的周次日期
76
+ currentWeekDates: [],
77
+ weekDays: [...['周一', '周二', '周三', '周四', '周五', '周六', '周日'].map((title, index) => {
78
+ const key = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][index]
79
+ return { title, key }
80
+ })],
81
+ // 排班时间表
82
+ shiftTable: [...['周一', '周二', '周三', '周四', '周五', '周六', '周日'].map((title, index) => {
83
+ const key = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][index]
84
+ return {
85
+ key, dataIndex: key, scopedSlots: { customRender: key }, slots: { title: key }, align: 'center', width: key === 'Monday' || key === 'Sunday' ? 170 : 120
86
+ }
87
+ }),
88
+ {
89
+ title: '排班数',
90
+ key: 'sk_limit',
91
+ dataIndex: 'sk_limit',
92
+ scopedSlots: { customRender: 'sk_limit' },
93
+ align: 'center'
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ props: {
99
+ // 配置名
100
+ queryParamsName: {
101
+ type: String,
102
+ default: ''
103
+ },
104
+ // 服务名
105
+ serviceName: {
106
+ type: String,
107
+ default: 'af-his'
108
+ }
109
+ },
110
+ computed: {
111
+ rowSelection () {
112
+ return {
113
+ selectedRowKeys: this.selectedRowKeys,
114
+ onChange: (selectedRowKeys, selectedRows) => {
115
+ this.onSelectChange(selectedRowKeys, selectedRows)
116
+ }
117
+ }
118
+ },
119
+ inputColumns () {
120
+ return this.columns.filter(col => col.type === 'input')
121
+ },
122
+ numberColumns () {
123
+ return this.columns.filter(col => col.type === 'number')
124
+ }
125
+ },
126
+ mounted () {
127
+ this.initWeekDates()
128
+ },
129
+ methods: {
130
+ handleShiftChange (day, index, record) {
131
+ // 找到当前记录在data中的索引
132
+ const dataIndex = this.data.findIndex(item => item.id === record.id)
133
+ if (dataIndex === -1) return
134
+ // 获取当前状态
135
+ const currentValue = record[day][index]
136
+ const newValue = currentValue === 1 || currentValue === '1' ? 0 : 1
137
+ // 更新按钮显示
138
+ this.$set(record[day], index, newValue)
139
+ // 同步更新data中的数据
140
+ this.$set(this.data[dataIndex][day], index, newValue)
141
+ },
142
+ onSelectChange (selectedRowKeys, selectedRows) {
143
+ this.selectedRowKeys = selectedRowKeys
144
+ this.selectedRows = selectedRows
145
+ },
146
+ // 处理输入框数据变化
147
+ handleInputChange (record, field, index, value) {
148
+ // 更新数据
149
+ this.$set(record[field], index, value)
150
+ },
151
+ // 获取选中的行数据
152
+ getSelectedRowData () {
153
+ if (this.pattern === 'form') {
154
+ // 在form模式下,返回包含输入框数据的完整信息
155
+ return this.selectedRows.map(row => {
156
+ const result = { ...row }
157
+ // 将对象格式的输入框数据转换为数组格式
158
+ this.inputColumns.forEach(col => {
159
+ if (row[col.dataIndex] && typeof row[col.dataIndex] === 'object') {
160
+ const fieldData = row[col.dataIndex]
161
+ const arrayData = []
162
+ // 将对象转换为数组,保持键的顺序
163
+ Object.keys(fieldData).forEach(key => {
164
+ arrayData.push(fieldData[key])
165
+ })
166
+ result[col.dataIndex] = arrayData
167
+ }
168
+ })
169
+ return result
170
+ })
171
+ }
172
+ return this.selectedRows
173
+ },
174
+ // 获取全部数据
175
+ getAllTable () {
176
+ return this.data
177
+ },
178
+ // 初始化数据
179
+ async init (queryParamsName) {
180
+ getConfigByName(queryParamsName, this.serviceName, result => {
181
+ this.configData = result
182
+ runLogic(result.dataSource, {}, this.serviceName).then(res => {
183
+ this.columns = []
184
+ this.columns = JSON.parse(JSON.stringify(this.configData.columns))
185
+ this.pattern = result.pattern
186
+ if (this.pattern == 'schedule') {
187
+ for (let i = 0; i < this.shiftTable.length; i++) {
188
+ this.columns.push(this.shiftTable[i])
189
+ }
190
+ if (res && Array.isArray(res)) {
191
+ const weekDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
192
+ const shifts = ['am', 'pm', 'evening']
193
+ let key = 0
194
+ this.data = res.map(item => {
195
+ const scheduleData = {
196
+ key: key++
197
+ }
198
+ this.configData.columnsName.forEach(columnName => { scheduleData[columnName] = item[columnName] })
199
+ weekDays.forEach(day => {
200
+ scheduleData[day.charAt(0).toUpperCase() + day.slice(1)] = shifts.map(shift => item[`f_${day}_${shift}`] === '1' ? 1 : 0)
201
+ })
202
+ return scheduleData
203
+ })
204
+ // 保存原始数据
205
+ this.originalData = JSON.parse(JSON.stringify(this.data))
206
+ }
207
+ } else if (this.pattern == 'form') {
208
+ const inputFields = this.configData.columns.filter(col => col.type === 'input').map(col => col.dataIndex)
209
+ this.data = res.map((item, index) => {
210
+ const newItem = {
211
+ ...item,
212
+ key: item.id || `form_row_${index}_${Date.now()}` // 确保每行有唯一的key
213
+ }
214
+ inputFields.forEach(field => {
215
+ const column = this.configData.columns.find(col => col.dataIndex === field)
216
+ if (column && column.type === 'input' && column.row) {
217
+ const rowCount = column.row.length || 1 // 默认长度1
218
+ // 创建对象格式的数据,键为1,2,3...,值为空字符串
219
+ const fieldData = {}
220
+ for (let i = 1; i <= rowCount; i++) {
221
+ fieldData[i] = ''
222
+ }
223
+ newItem[field] = fieldData
224
+ } else {
225
+ newItem[field] = item[field] || ''
226
+ }
227
+ })
228
+ return newItem
229
+ })
230
+ }
231
+ })
232
+ })
233
+ },
234
+ // 查询数据函数
235
+ filterTableData (filters) {
236
+ if (!filters || Object.keys(filters).length === 0) {
237
+ // 如果没有过滤条件,恢复原始数据
238
+ this.data = JSON.parse(JSON.stringify(this.originalData))
239
+ return
240
+ }
241
+ // 从原始数据开始过滤
242
+ this.data = this.originalData.filter(item => {
243
+ // 检查每一项是否满足所有过滤条件
244
+ return Object.entries(filters).every(([key, value]) => {
245
+ // 如果过滤值是字符串,进行模糊匹配
246
+ if (typeof value === 'string') {
247
+ return item[key] && item[key].toString().toLowerCase().includes(value.toLowerCase())
248
+ }
249
+ // 如果过滤值是数字,进行精确匹配
250
+ return item[key] === value
251
+ })
252
+ }).map((item, index) => ({
253
+ ...item,
254
+ key: item.key || item.id || `filtered_row_${index}_${Date.now()}` // 确保过滤后的数据也有唯一key
255
+ }))
256
+ },
257
+ // 初始化周次日期
258
+ initWeekDates () {
259
+ const today = new Date()
260
+ const currentDay = today.getDay() || 7 // 将周日的0转换为7
261
+ const monday = new Date(today)
262
+ monday.setDate(today.getDate() - currentDay + 1) // 设置为本周一
263
+ this.currentWeekDates = Array.from({ length: 7 }, (_, index) => {
264
+ const date = new Date(monday)
265
+ date.setDate(monday.getDate() + index)
266
+ return date
267
+ })
268
+ },
269
+ // 切换到上一周
270
+ handleLastWeek () {
271
+ const monday = new Date(this.currentWeekDates[0])
272
+ monday.setDate(monday.getDate() - 7)
273
+ this.updateWeekDates(monday)
274
+ },
275
+ // 切换到下一周
276
+ handleNextWeek () {
277
+ const monday = new Date(this.currentWeekDates[0])
278
+ monday.setDate(monday.getDate() + 7)
279
+ this.updateWeekDates(monday)
280
+ },
281
+ // 更新周次日期
282
+ updateWeekDates (monday) {
283
+ this.currentWeekDates = Array.from({ length: 7 }, (_, index) => {
284
+ const date = new Date(monday)
285
+ date.setDate(monday.getDate() + index)
286
+ return date
287
+ })
288
+ },
289
+ // 判断某行是否被选中
290
+ isRowSelected (rowKey) {
291
+ return this.selectedRowKeys.includes(rowKey)
292
+ }
293
+ },
294
+ watch: {
295
+ queryParamsName: {
296
+ handler (newValue) {
297
+ this.init(newValue)
298
+ },
299
+ deep: true,
300
+ immediate: true
301
+ }
302
+ }
303
+ }
304
+ </script>
305
+
306
+ <style scoped>
307
+ .time-title {
308
+ display: flex !important;
309
+ flex-direction: column !important;
310
+ align-items: center !important;
311
+ }
312
+ .week_last_next_btn {
313
+ display: flex;
314
+ flex-direction: row;
315
+ align-items: center;
316
+ justify-content: center;
317
+ gap: 16px;
318
+ }
319
+ ::v-deep .ant-table-thead > tr > th,
320
+ ::v-deep .ant-table-tbody > tr > td {
321
+ padding: 8px 16px !important;
322
+ overflow-wrap: break-word;
323
+ }
324
+ .ant-input {
325
+ width: 100%;
326
+ }
327
+ .a-div{
328
+ display: flex;
329
+ flex-direction: column;
330
+ }
331
+ .number{
332
+ box-sizing: border-box;
333
+ margin: 0;
334
+ padding: 0;
335
+ font-variant: tabular-nums;
336
+ list-style: none;
337
+ font-feature-settings: 'tnum';
338
+ position: relative;
339
+ display: inline-block;
340
+ width: 100%;
341
+ height: 32px;
342
+ padding: 4px 11px;
343
+ color: rgba(0, 0, 0, 0.65);
344
+ font-size: 14px;
345
+ line-height: 1.5;
346
+ background-image: none;
347
+ border-radius: 4px;
348
+ transition: all 0.3s;
349
+ }
350
+ </style>
@@ -0,0 +1,355 @@
1
+ <template>
2
+ <div v-if="pattern == 'schedule'">
3
+ <a-table
4
+ :columns="columns"
5
+ :data-source="data"
6
+ :rowSelection="rowSelection"
7
+ :scroll="{ y: configData.height == null? '70%' : configData.height }">
8
+ <span slot="time" class="time-title">
9
+ <span v-for="(item, index) in configData.timePeriod" :key="index">{{ item }}</span>
10
+ </span>
11
+ <div v-for="(item, index) in weekDays" :key="index" :slot="item.key" class="week_last_next_btn">
12
+ <a-button slot="lastWeek" icon="left" size="large" @click="handleLastWeek" v-if="item.title == '周一'" />
13
+ <div class="time-title">
14
+ <span>{{ item.title }}</span>
15
+ <span>{{ currentWeekDates[index].toLocaleDateString() }}</span>
16
+ </div>
17
+ <a-button slot="nextWeek" icon="right" size="large" @click="handleNextWeek" v-if="item.title == '周日'"/>
18
+ </div>
19
+ <template :slot="day.key" slot-scope="text, record" v-for="day in shiftTable">
20
+ <div class="time-title" :key="day.key">
21
+ <a-button v-for="(item, index) in record[day.key]" :key="index" @click="handleShiftChange(day.key, index, record)">{{ item === 1 || item === '1' ? '坐诊' : '休息' }}</a-button>
22
+ </div>
23
+ </template>
24
+ <template slot="sk_limit" slot-scope="text, record">
25
+ <a-input-number id="inputNumber" v-model="record.sk_limit" :min="configData.sk_limitMin" :max="configData.sk_limitMax" />
26
+ </template>
27
+ </a-table>
28
+ </div>
29
+ <div v-else-if="pattern == 'form'">
30
+ <a-table :columns="columns" :data-source='data' :row-selection="rowSelection" bordered :scroll="{ y: configData.height == null? '70%' : configData.height }">
31
+ <template v-for="(n, i) in inputColumns" :slot="n.dataIndex" slot-scope="text, record">
32
+ <div class="a-div" :key="i">
33
+ <a-input
34
+ v-for="(item, index) in n.row"
35
+ :key="index"
36
+ placeholder=""
37
+ class="ant-input"
38
+ v-model="record[n.dataIndex][index + 1]"
39
+ @input="handleInputChange(record, n.dataIndex, index + 1, $event.target.value)"
40
+ :disabled="!isRowSelected(record.key)"
41
+ />
42
+ </div>
43
+ </template>
44
+ <div class="a-div" v-for="(n, i) in numberColumns" :slot="n.dataIndex" :key="i">
45
+ <div v-for="(item, index) in n.row" :key="index" class="number">{{item}}</div>
46
+ </div>
47
+ </a-table>
48
+ </div>
49
+ </template>
50
+ <script>
51
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
52
+
53
+ export default {
54
+ data () {
55
+ return {
56
+ // 高度
57
+ height: '70%',
58
+ // 输入框数据
59
+ inputData: [],
60
+ // 模式
61
+ pattern: 'schedule',
62
+ data: [],
63
+ // 列配置
64
+ columns: [],
65
+ // 列名
66
+ columnNames: [],
67
+ // 选中的行键值集合
68
+ selectedRows: [],
69
+ // 选中的行信息集合
70
+ selectedRowKeys: [],
71
+ // 原始数据备份
72
+ originalData: [],
73
+ // 配置参数
74
+ configData: {},
75
+ // 当前显示的周次日期
76
+ currentWeekDates: [],
77
+ weekDays: [...['周一', '周二', '周三', '周四', '周五', '周六', '周日'].map((title, index) => {
78
+ const key = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][index]
79
+ return { title, key }
80
+ })],
81
+ // 排班时间表
82
+ shiftTable: [...['周一', '周二', '周三', '周四', '周五', '周六', '周日'].map((title, index) => {
83
+ const key = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][index]
84
+ return {
85
+ key, dataIndex: key, scopedSlots: { customRender: key }, slots: { title: key }, align: 'center', width: key === 'Monday' || key === 'Sunday' ? 170 : 120
86
+ }
87
+ }),
88
+ {
89
+ title: '排班数',
90
+ key: 'sk_limit',
91
+ dataIndex: 'sk_limit',
92
+ scopedSlots: { customRender: 'sk_limit' },
93
+ align: 'center'
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ props: {
99
+ // 配置名
100
+ queryParamsName: {
101
+ type: String,
102
+ default: ''
103
+ },
104
+ // 服务名
105
+ serviceName: {
106
+ type: String,
107
+ default: 'af-his'
108
+ }
109
+ },
110
+ computed: {
111
+ rowSelection () {
112
+ return {
113
+ selectedRowKeys: this.selectedRowKeys,
114
+ onChange: (selectedRowKeys, selectedRows) => {
115
+ this.onSelectChange(selectedRowKeys, selectedRows)
116
+ }
117
+ }
118
+ },
119
+ inputColumns () {
120
+ return this.columns.filter(col => col.type === 'input')
121
+ },
122
+ numberColumns () {
123
+ return this.columns.filter(col => col.type === 'number')
124
+ }
125
+ },
126
+ mounted () {
127
+ this.initWeekDates()
128
+ },
129
+ methods: {
130
+ handleShiftChange (day, index, record) {
131
+ // 找到当前记录在data中的索引
132
+ const dataIndex = this.data.findIndex(item => item.id === record.id)
133
+ if (dataIndex === -1) return
134
+ // 获取当前状态
135
+ const currentValue = record[day][index]
136
+ const newValue = currentValue === 1 || currentValue === '1' ? 0 : 1
137
+ // 更新按钮显示
138
+ this.$set(record[day], index, newValue)
139
+ // 同步更新data中的数据
140
+ this.$set(this.data[dataIndex][day], index, newValue)
141
+ },
142
+ onSelectChange (selectedRowKeys, selectedRows) {
143
+ this.selectedRowKeys = selectedRowKeys
144
+ this.selectedRows = selectedRows
145
+ },
146
+ // 处理输入框数据变化
147
+ handleInputChange (record, field, index, value) {
148
+ // 更新数据
149
+ this.$set(record[field], index, value)
150
+ },
151
+ // 获取选中的行数据
152
+ getSelectedRowData () {
153
+ if (this.pattern === 'form') {
154
+ // 在form模式下,返回包含输入框数据的完整信息
155
+ return this.selectedRows.map(row => {
156
+ const result = { ...row }
157
+ // 将对象格式的输入框数据转换为数组格式
158
+ this.inputColumns.forEach(col => {
159
+ if (row[col.dataIndex] && typeof row[col.dataIndex] === 'object') {
160
+ const fieldData = row[col.dataIndex]
161
+ const arrayData = []
162
+ // 将对象转换为数组,保持键的顺序
163
+ Object.keys(fieldData).forEach(key => {
164
+ arrayData.push(fieldData[key])
165
+ })
166
+ result[col.dataIndex] = arrayData
167
+ }
168
+ })
169
+ return result
170
+ })
171
+ }
172
+ return this.selectedRows
173
+ },
174
+ // 获取全部数据
175
+ getAllTable () {
176
+ return this.data
177
+ },
178
+ // 初始化数据
179
+ async init (queryParamsName) {
180
+ getConfigByName(queryParamsName, this.serviceName, result => {
181
+ this.configData = result
182
+ runLogic(result.dataSource, {}, this.serviceName).then(res => {
183
+ this.columns = []
184
+ this.columns = JSON.parse(JSON.stringify(this.configData.columns))
185
+ this.pattern = result.pattern
186
+ if (this.pattern == 'schedule') {
187
+ for (let i = 0; i < this.shiftTable.length; i++) {
188
+ this.columns.push(this.shiftTable[i])
189
+ }
190
+ if (res && Array.isArray(res)) {
191
+ const weekDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
192
+ const shifts = ['am', 'pm', 'evening']
193
+ let key = 0
194
+ this.data = res.map(item => {
195
+ const scheduleData = {
196
+ key: key++
197
+ }
198
+ this.configData.columnsName.forEach(columnName => { scheduleData[columnName] = item[columnName] })
199
+ weekDays.forEach(day => {
200
+ scheduleData[day.charAt(0).toUpperCase() + day.slice(1)] = shifts.map(shift => item[`f_${day}_${shift}`] === '1' ? 1 : 0)
201
+ })
202
+ return scheduleData
203
+ })
204
+ // 保存原始数据
205
+ this.originalData = JSON.parse(JSON.stringify(this.data))
206
+ }
207
+ } else if (this.pattern == 'form') {
208
+ const inputFields = this.configData.columns.filter(col => col.type === 'input').map(col => col.dataIndex)
209
+ this.data = res.map((item, index) => {
210
+ const newItem = {
211
+ ...item,
212
+ key: item.id || `form_row_${index}_${Date.now()}` // 确保每行有唯一的key
213
+ }
214
+ inputFields.forEach(field => {
215
+ const column = this.configData.columns.find(col => col.dataIndex === field)
216
+ if (column && column.type === 'input' && column.row) {
217
+ const rowCount = column.row.length || 1 // 默认长度1
218
+ // 创建对象格式的数据,键为1,2,3...,值为空字符串
219
+ const fieldData = {}
220
+ for (let i = 1; i <= rowCount; i++) {
221
+ fieldData[i] = ''
222
+ }
223
+ newItem[field] = fieldData
224
+ } else {
225
+ newItem[field] = item[field] || ''
226
+ }
227
+ })
228
+ return newItem
229
+ })
230
+ }
231
+ })
232
+ })
233
+ },
234
+ // 查询数据函数
235
+ filterTableData (filters) {
236
+ if (!filters || Object.keys(filters).length === 0) {
237
+ // 如果没有过滤条件,恢复原始数据
238
+ this.data = JSON.parse(JSON.stringify(this.originalData))
239
+ return
240
+ }
241
+ // 从原始数据开始过滤
242
+ this.data = this.originalData.filter(item => {
243
+ // 检查每一项是否满足所有过滤条件
244
+ return Object.entries(filters).every(([key, value]) => {
245
+ // 如果过滤值是字符串,进行模糊匹配
246
+ if (typeof value === 'string') {
247
+ return item[key] && item[key].toString().toLowerCase().includes(value.toLowerCase())
248
+ }
249
+ // 如果过滤值是数字,进行精确匹配
250
+ return item[key] === value
251
+ })
252
+ }).map((item, index) => ({
253
+ ...item,
254
+ key: item.key || item.id || `filtered_row_${index}_${Date.now()}` // 确保过滤后的数据也有唯一key
255
+ }))
256
+ },
257
+ // 初始化周次日期
258
+ initWeekDates () {
259
+ const today = new Date()
260
+ const currentDay = today.getDay() || 7 // 将周日的0转换为7
261
+ const monday = new Date(today)
262
+ monday.setDate(today.getDate() - currentDay + 1) // 设置为本周一
263
+ this.currentWeekDates = Array.from({ length: 7 }, (_, index) => {
264
+ const date = new Date(monday)
265
+ date.setDate(monday.getDate() + index)
266
+ return date
267
+ })
268
+ },
269
+ // 切换到上一周
270
+ handleLastWeek () {
271
+ const monday = new Date(this.currentWeekDates[0])
272
+ monday.setDate(monday.getDate() - 7)
273
+ this.updateWeekDates(monday)
274
+ },
275
+ // 切换到下一周
276
+ handleNextWeek () {
277
+ const monday = new Date(this.currentWeekDates[0])
278
+ monday.setDate(monday.getDate() + 7)
279
+ this.updateWeekDates(monday)
280
+ },
281
+ // 更新周次日期
282
+ updateWeekDates (monday) {
283
+ this.currentWeekDates = Array.from({ length: 7 }, (_, index) => {
284
+ const date = new Date(monday)
285
+ date.setDate(monday.getDate() + index)
286
+ return date
287
+ })
288
+ },
289
+ // 判断某行是否被选中
290
+ isRowSelected (rowKey) {
291
+ return this.selectedRowKeys.includes(rowKey)
292
+ }
293
+ },
294
+ watch: {
295
+ queryParamsName: {
296
+ handler (newValue) {
297
+ this.init(newValue)
298
+ },
299
+ deep: true,
300
+ immediate: true
301
+ }
302
+ }
303
+ }
304
+ </script>
305
+
306
+ <style scoped>
307
+ .time-title {
308
+ display: flex !important;
309
+ flex-direction: column !important;
310
+ align-items: center !important;
311
+ }
312
+ .week_last_next_btn {
313
+ display: flex;
314
+ flex-direction: row;
315
+ align-items: center;
316
+ justify-content: center;
317
+ gap: 16px;
318
+ }
319
+ ::v-deep .ant-table-thead > tr > th,
320
+ ::v-deep .ant-table-tbody > tr > td {
321
+ padding: 8px 16px !important;
322
+ overflow-wrap: break-word;
323
+ }
324
+ .ant-input {
325
+ width: 100%;
326
+ }
327
+ .ant-input[disabled] {
328
+ background-color: #f5f5f5;
329
+ color: #999;
330
+ cursor: not-allowed;
331
+ }
332
+ .a-div{
333
+ display: flex;
334
+ flex-direction: column;
335
+ }
336
+ .number{
337
+ box-sizing: border-box;
338
+ margin: 0;
339
+ padding: 0;
340
+ font-variant: tabular-nums;
341
+ list-style: none;
342
+ font-feature-settings: 'tnum';
343
+ position: relative;
344
+ display: inline-block;
345
+ width: 100%;
346
+ height: 32px;
347
+ padding: 4px 11px;
348
+ color: rgba(0, 0, 0, 0.65);
349
+ font-size: 14px;
350
+ line-height: 1.5;
351
+ background-image: none;
352
+ border-radius: 4px;
353
+ transition: all 0.3s;
354
+ }
355
+ </style>