CD配唱片
2025-04-27 df389f166dea10fe770a57d9e04bb1af59dfd493
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
<template>
  <div class="app-container">
    <el-form
      class="responsive-form"
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-row type="flex" justify="left">
        <el-col :span="6">
          <el-form-item label="日历描述" prop="description">
            <el-input
              style="width: 140px"
              v-model="queryParams.description"
              placeholder="请输入描述关键词"
              clearable
              @keyup.enter="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="18" style="text-align: right">
          <el-form-item class="column-with-margin">
            <el-button type="primary" icon="Search" @click="handleQuery"
              >查询</el-button
            >
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
 
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['aps:calendar:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['aps:calendar:update']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['aps:calendar:remove']"
          >删除</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['core:calendar:export']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <HxlhTable
      style="width: 100%"
      :columns="columns"
      :data="calendarList"
      :loading="loading"
      :height="height"
      ref="tableRef"
      :page="page"
      @changePageNo="changePageNo"
      @changePageSize="changePageSize"
      @on-checkbox="handleCheckboxChange"
      class="auto-height-grid"
    >
      <template #status="{ row }">
        <vxe-tag v-if="row.type === '1'" status="primary">周工作日</vxe-tag>
        <vxe-tag v-if="row.type === '2'" status="success">节假日</vxe-tag>
      </template>
      <template #mark="{ row }">
        <div v-if="row.type === '1'">
          <span
            v-for="(item, index) in JSON.parse(row.content.value).weekdays"
            :key="index"
          >
            <span v-if="item.work === 'y'" status="success" class="mart5"
              >{{ item.chineseName }}: 工作日;&nbsp;</span
            >
            <span v-if="item.work === 'n'" status="info" class="mart5"
              >{{ item.chineseName }}: 非工作日;&nbsp;</span
            >
          </span>
          <!-- <div v-for="(item, index) in JSON.parse(row.content.value).weekdays" :key="index">
              <vxe-tag v-if="item.work==='y'" status="success" class="mart5">{{item.chineseName}}: 工作日;&nbsp;</vxe-tag>
              <vxe-tag v-if="item.work==='n'" status="info" class="mart5">{{item.chineseName}}: 非工作日;&nbsp;</vxe-tag>
            </div> -->
        </div>
        <div v-if="row.type === '2'">
          <div>
            {{ JSON.parse(row.content.value).holidays.startdate }}至{{
              JSON.parse(row.content.value).holidays.enddate
            }}
          </div>
        </div>
      </template>
      <template #buttons="{ row }">
        <vxe-button
          mode="text"
          @click="handleUpdate(row)"
          v-hasPermi="['aps:calendar:update']"
          >修改</vxe-button
        >
        <vxe-button
          mode="text"
          @click="handleDelete(row)"
          v-hasPermi="['aps:calendar:remove']"
          >删除</vxe-button
        >
      </template>
    </HxlhTable>
 
    <!-- 添加或修改日历管理对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form
        ref="calendarRef"
        :model="form"
        :rules="rules"
        label-width="105px"
      >
        <el-form-item label="日历描述" prop="description">
          <el-input v-model="form.description" placeholder="请输入描述" />
        </el-form-item>
        <el-form-item label="日历类型" prop="type">
          <el-radio-group v-model="form.type" @change="handleSwitchType">
            <el-radio :label="'1'">周工作</el-radio>
            <el-radio :label="'2'">节假日</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="生效时间" prop="effectiveDate">
          <el-date-picker
            clearable
            v-model="form.effectiveDate"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="失效时间" prop="expiringDate">
          <el-date-picker
            clearable
            v-model="form.expiringDate"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <div v-if="form.type === '1'">
          <div class="title_bar_line">
            <div class="line_short"></div>
            <div>周工作设置</div>
            <div class="line_long"></div>
          </div>
          <div
            class="week_flex"
            v-for="(item, index) in weekDaysSettingList"
            :key="index"
          >
            <div class="week_flex_item">{{ item.chineseName }}</div>
            <div class="week_flex_item">
              <el-radio-group v-model="item.work">
                <el-radio :label="'y'">工作日</el-radio>
                <el-radio :label="'n'">非工作日</el-radio>
              </el-radio-group>
            </div>
          </div>
        </div>
        <div v-if="form.type === '2'">
          <div class="title_bar_line">
            <div class="line_short"></div>
            <div>节假日设置</div>
            <div class="line_long"></div>
          </div>
          <div class="week_flex mt20">
            <div class="week_flex_item">节日开始时间</div>
            <div class="week_flex_item">
              <el-date-picker
                clearable
                v-model="holidays.startdate"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="选择日期"
              >
              </el-date-picker>
            </div>
          </div>
          <div class="week_flex mt20">
            <div class="week_flex_item">节日结束时间</div>
            <div class="week_flex_item">
              <el-date-picker
                clearable
                v-model="holidays.enddate"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="选择日期"
              >
              </el-date-picker>
            </div>
          </div>
        </div>
        <el-form-item
          label="适用工厂"
          prop="applicableFactory"
          class="factory_use_item"
        >
          <el-select
            clearable
            v-model="form.applicableFactory"
            style="width: 160px"
            placeholder="请输入适用工厂"
            @change="changePlant($event)"
          >
            <el-option
              v-for="plant in plantList"
              :key="plant.id"
              :label="plant.plantName"
              :value="plant.plantCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="适用车间"
          prop="applicableWorkshop"
          class="factory_use_item"
        >
          <el-select
            clearable
            v-model="form.applicableWorkshop"
            style="width: 160px"
            placeholder="请输入适用车间"
          >
            <el-option
              v-for="shop in shopList"
              :key="shop.id"
              :label="shop.shopName"
              :value="shop.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="适用工序"
          prop="applicableProcess"
          class="factory_use_item"
        >
          <el-select
            clearable
            v-model="form.applicableProcess"
            style="width: 160px"
            placeholder="请输入适用工序"
          >
            <el-option
              v-for="process in processList"
              :key="process.id"
              :label="process.processName"
              :value="process.processName"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">取 消</el-button>
          <el-button type="primary" @click="submitForm">保存</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup name="Calendar">
import HxlhTable from "@/components/HxlhTable";
import {
  listCalendar,
  getCalendar,
  delCalendar,
  addCalendar,
  updateCalendar,
} from "@/api/basicData/calendar";
import axios from "axios";
import { listAll_plant } from "@/api/basicData/plant";
import { listAll_shop, listAps_shop } from "@/api/basicData/shop";
import { selectProcessNameList } from "@/api/basicData/processRoute.js";
const { proxy } = getCurrentInstance();
const tableRef = ref();
const calendarList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
  form: {
    type: "1",
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    description: null,
    type: null,
    effectiveDate: null,
    expiringDate: null,
    content: null,
    applicableFactory: null,
    applicableWorkshop: null,
    applicableProcess: null,
  },
  rules: {
    description: [
      {
        required: true,
        message: "请输入日历描述",
        trigger: "blur",
      },
    ],
    type: [
      {
        required: true,
        message: "请选择日历类型",
        trigger: "blur",
      },
    ],
    effectiveDate: [
      {
        required: true,
        message: "请选择日历生效时间",
        trigger: "blur",
      },
    ],
    expiringDate: [
      {
        required: true,
        message: "请选择日历失效时间",
        trigger: "blur",
      },
    ],
    applicableFactory: [
      {
        required: true,
        message: "请选择适用工厂",
        trigger: "blur",
      },
    ],
  },
});
const { queryParams, form, rules } = toRefs(data);
const dateType = ref("周工作");
const dateTypeList = ref([
  {
    name: "周工作",
    label: "1",
  },
  {
    name: "节假日",
    label: "2",
  },
]);
const typeRadioNumber = ref(1);
const weekDaysSettingList = ref([
  {
    day: "Monday",
    chineseName: "星期一",
    work: "y",
  },
  {
    day: "TuesDay",
    chineseName: "星期二",
    work: "y",
  },
  {
    day: "Wednesday",
    chineseName: "星期三",
    work: "y",
  },
  {
    day: "Thursday",
    chineseName: "星期四",
    work: "y",
  },
  {
    day: "Friday",
    chineseName: "星期五",
    work: "y",
  },
  {
    day: "Saturday",
    chineseName: "星期六",
    work: "y",
  },
  {
    day: "Sunday",
    chineseName: "星期日",
    work: "y",
  },
]);
const holidays = ref({
  startdate: "",
  enddate: "",
});
const plantList = ref([]);
const shopList = ref([]);
const allShopList = ref([]);
const processList = ref([]);
const height = ref(document.documentElement.clientHeight - 220 + "px;");
// 表格配置-列表
const columns = ref([
  { type: "checkbox", width: 60, align: "center" },
  {
    title: "日历描述",
    field: "description",
    width: 150,
    align: "center",
  },
  {
    title: "日历类型",
    field: "type",
    width: 200,
    align: "center",
    slots: { default: "status" },
  },
  {
    title: "日历生效时间",
    field: "effectiveDate",
    width: 200,
    align: "center",
  },
  {
    title: "日历失效时间",
    field: "expiringDate",
    width: 200,
    align: "center",
  },
  {
    title: "日历内容",
    field: "content",
    width: 230,
    align: "center",
    slots: { default: "mark" },
  },
  {
    title: "适用工厂",
    field: "applicableFactory",
    width: 200,
    align: "center",
    formatter: ({ cellValue, row, column }) => {
      if (cellValue) {
        for (let i = 0; i < plantList.value.length; i++) {
          if (cellValue === plantList.value[i].plantCode) {
            return plantList.value[i].plantName;
          }
        }
      }
    },
  },
  {
    title: "适用车间",
    field: "applicableWorkshop",
    width: 200,
    align: "center",
    formatter: ({ cellValue, row, column }) => {
      if (cellValue) {
        for (let i = 0; i < shopList.value.length; i++) {
          if (cellValue === shopList.value[i].id) {
            return shopList.value[i].shopName;
          }
        }
      }
      return "";
    },
  },
  {
    title: "适用工序",
    field: "applicableProcess",
    width: 200,
    align: "center",
  },
  {
    title: "创建者",
    field: "createBy",
    width: 200,
    align: "center",
  },
  {
    title: "创建时间",
    field: "createTime",
    width: 200,
    align: "center",
  },
  {
    title: "操作",
    width: 100,
    fixed: "right",
    slots: { default: "buttons" },
    align: "center",
  },
]);
// 分页属性
const page = ref({
  total: 0,
  current: 1,
  size: 10,
});
 
/** 查询日历管理列表 */
function getList() {
  loading.value = true;
  listCalendar(queryParams.value).then((response) => {
    calendarList.value = response.rows;
    page.value.total = response.total;
    loading.value = false;
  });
  axios
    .all([
      /** 查询工厂列表 */
      listAll_plant({}),
      /** 查询车间列表 */
      listAll_shop({}),
    ])
    .then(
      axios.spread((response1, response2) => {
        plantList.value = response1.data;
        shopList.value = response2.data;
        loading.value = false;
      })
    )
    .catch((error) => {
      console.error("请求出错:", error);
    });
}
 
// 取消按钮
function cancel() {
  open.value = false;
  reset();
}
 
// 表单重置
function reset() {
  form.value = {
    id: null,
    description: null,
    type: "1",
    effectiveDate: null,
    expiringDate: null,
    content: null,
    applicableFactory: null,
    applicableWorkshop: null,
    applicableProcess: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm("calendarRef");
}
 
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
 
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
 
// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
 
/** 新增按钮操作 */
async function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加日历管理";
}
/** 选择工厂后事件 加载车间 和 工序 **/
function changePlant(plant) {
  listAps_shop({ plantCode: plant }).then((response) => {
    shopList.value = response.rows;
  });
  selectProcessNameList({ orgCode: plant }).then((response) => {
    processList.value = response.rows;
  });
}
/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getCalendar(_id).then((response) => {
    form.value = response.data;
    // form.value.content = JSON.parse(response.data.content.value);
    if (form.value.type === "1") {
      weekDaysSettingList.value = JSON.parse(
        response.data.content.value
      ).weekdays;
    } else if (form.value.type === "2") {
      holidays.value = JSON.parse(response.data.content.value).holidays;
    }
 
    open.value = true;
    title.value = "修改日历管理";
  });
}
 
/** 提交按钮 */
function submitForm() {
  proxy.$refs["calendarRef"].validate((valid) => {
    if (valid) {
      if (form.value.id != null) {
        if (form.value.type === "1") {
          updateCalendar({
            ...form.value,
            content: {
              weekdays: weekDaysSettingList.value,
            },
            applicableWorkshop: form.value.applicableWorkshop,
            applicableProcess: form.value.applicableProcess,
          }).then((response) => {
            proxy.$modal.msgSuccess("修改成功");
            open.value = false;
            getList();
          });
        } else if (form.value.type === "2") {
          updateCalendar({
            ...form.value,
            content: {
              holidays: holidays.value,
            },
            applicableWorkshop: form.value.applicableWorkshop,
            applicableProcess: form.value.applicableProcess,
          }).then((response) => {
            proxy.$modal.msgSuccess("修改成功");
            open.value = false;
            getList();
          });
        }
      } else {
        if (form.value.type === "1") {
          addCalendar({
            ...form.value,
            content: {
              weekdays: weekDaysSettingList.value,
            },
          }).then((response) => {
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          });
        } else if (form.value.type === "2") {
          addCalendar({
            ...form.value,
            content: {
              holidays: holidays.value,
            },
          }).then((response) => {
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          });
        }
      }
    }
  });
}
 
/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除日历管理编号为"' + _ids + '"的数据项?')
    .then(function () {
      return delCalendar(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
 
/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "core/calendar/export",
    {
      ...queryParams.value,
    },
    `calendar_${new Date().getTime()}.xlsx`
  );
}
function handleSwitchType(e) {
  typeRadioNumber.value = e;
  form.value.type = e;
  form.value.effectiveDate = null;
  form.value.expiringDate = null;
  form.value.content = null;
  form.value.applicableFactory = null;
  form.value.applicableWorkshop = null;
  form.value.applicableProcess = null;
}
function changePageNo(currentPage) {
  queryParams.value.pageNum = currentPage;
  page.value.current = currentPage;
  getList();
}
function changePageSize(pageSize) {
  page.value.current = 1;
  queryParams.value.pageNum = 1;
  queryParams.value.pageSize = pageSize;
  getList();
}
// 多选框选中数据
const handleCheckboxChange = (data) => {
  ids.value = data.records.map((item) => item.id);
  single.value = data.records.length !== 1;
  multiple.value = !data.records.length;
};
onMounted(() => {
  getList();
});
</script>
<style lang="scss" scoped>
.column-with-margin {
  margin-right: 0px;
}
.title_bar_line {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  color: #333;
  margin-bottom: 10px;
  .line_short {
    width: 5%;
    height: 1px;
    margin-right: 20px;
    border-top: 1px solid #ddd;
  }
  .line_long {
    width: 60%;
    height: 1px;
    margin-left: 20px;
    border-top: 1px solid #ddd;
  }
}
.week_flex {
  display: flex;
  justify-content: flex-start;
  align-content: center;
  color: #606266;
  font-weight: 700;
  margin-left: 20px;
  &.mt20 {
    margin-top: 20px;
    margin-left: 0 !important;
  }
  .week_flex_item {
    &:nth-child(1) {
      margin-top: 5px;
    }
    &:nth-child(2) {
      margin-left: 20px;
    }
  }
}
.factory_use_item {
  margin-top: 10px;
}
.mart5 {
  margin-top: 5px;
}
.custom-height {
  height: 200px; /* 或者使用 min-height */
}
.auto-height-grid .xe-body .xe-body--row {
  height: auto; /* 或者使用 min-height */
}
</style>