From 49cb46e0c203ec08939f67759ba2d2c45cb25788 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 21 May 2025 16:03:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/yearHoliday.js | 35 +++ src/utils/formBuilder.js | 223 ++++++++++----- .../attendance/components/addYearHoliday.vue | 119 ++++++++ src/views/attendance/yearHoliday.vue | 266 ++++++++++++++++++ 4 files changed, 566 insertions(+), 77 deletions(-) create mode 100644 src/api/yearHoliday.js create mode 100644 src/views/attendance/components/addYearHoliday.vue create mode 100644 src/views/attendance/yearHoliday.vue diff --git a/src/api/yearHoliday.js b/src/api/yearHoliday.js new file mode 100644 index 0000000..29544f7 --- /dev/null +++ b/src/api/yearHoliday.js @@ -0,0 +1,35 @@ +import request from '@/utils/request'; + +export function index (params) { + return request({ + url: "/api/oa/year-holiday-plan/index", + method: "get", + params + }) +} + +export function save (data) { + return request({ + url: "/api/oa/year-holiday-plan/save", + method: "post", + data + }) +} + +export function show (params) { + return request({ + url: "/api/oa/year-holiday-plan/show", + method: "get", + params + }) +} + +export function destroy (params) { + return request({ + url: "/api/oa/year-holiday-plan/destroy", + method: "get", + params + }) +} + + diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index a0afc8f..e449020 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -454,93 +454,162 @@ export default function formBuilder( this.$set(this.flows, info.name, res.data.data); }); } - formItem = h( - "el-select", - { - ref: `relation-flow-${info.name}`, - props: { - value: target[info.name] - ? target[info.name] - .toString() - ?.split(",") - .map((i) => Number(i)) - : [], - clearable: true, - placeholder: info.help_text || '输入标题或编号搜索流程..', - multiple: true, - filterable: true, - "reserve-keyword": true, - "filter-method": debounce((query) => { - this.tempFlowList = this.flows[info.name].filter(flow => new RegExp(query, 'i').test(flow.title + flow.no)) - console.log(query) - if (this.tempFlowList.length === 0) { - Message.warning("未搜索到匹配流程") - } - }, 500).bind(this) - }, - attrs: { - placeholder: info.help_text, - }, + formItem = h("div", { style: { - width: "100%", - }, - on: { - input: (e) => { - this.$set(target, info.name, e.toString()); - this.tempFlowList.length = 0; - }, - }, - }, - (this.tempFlowList.length > 0 ? this.tempFlowList : this.flows[info.name])?.map((option) => - h("el-option", { + // display: "flex", + // gap: "10px", + // alignItems: "flex-start" + } + }, [ + // 原有的 el-select + h("el-select", { + ref: `relation-flow-${info.name}`, props: { - label: option.title, - value: option.id, + value: target[info.name] ? target[info.name].toString()?.split(",").map(Number) : [], + clearable: true, + placeholder: info.help_text || '输入标题或编号搜索流程..', + multiple: true, + filterable: true, + "reserve-keyword": true, + "filter-method": debounce((query) => { + this.tempFlowList = this.handleFlowFilter(query, this.flows[info.name]); + }, 500) + }, + style: { + width: "100%", + }, + on: { + input: (e) => { + this.$set(target, info.name, e.toString()); + this.tempFlowList = []; + console.log("target",target[info.name] ? target[info.name].toString()?.split(",").map(Number) : []) + }, }, - }, [ - h("div", { + }, (this.tempFlowList.length > 0 ? this.tempFlowList : this.flows[info.name])?.map((option) => + h("el-option", { + props: { + label: option.title, + value: option.id, + }, + }, [ + h("div", {}, [ + h("span", {}, option.title), + h("el-button", { + style: { + float: 'right' + }, + props: { + type: 'primary', + size: 'mini', + icon: 'el-icon-search' + }, + on: { + click: (e) => { + e.stopPropagation() + let target = this.$router.resolve({ + path: "/flow/detail", + query: { + module_id: option.custom_model_id, + flow_id: option.id, + isSinglePage: 1, + }, + }) + this.modalRender = (h) => + h("iframe", { + attrs: { + src: target.href, + }, + style: { + border: "none", + width: "100%", + height: "100%", + }, + }); + this.isShowModal = true; + this.$refs[`relation-flow-${info.name}`]?.blur() + } + } + }, '查看') + ]) + ]) + )), + + // 新增的已选项显示区域 + h("div", { + style: { + flex: "1", + display: "flex", + flexWrap: "wrap", + gap: "6px" + } + }, target[info.name] ? target[info.name].toString().split(",").map(id => { + const selectedFlow = this.flows[info.name].find(flow => flow.id === Number(id)); + if (!selectedFlow) return null; + + return h("div", { + style: { + padding: "4px 8px", + background: "#f0f2f5", + borderRadius: "4px", + cursor: "pointer", + display: "flex", + alignItems: "center", + gap: "4px", + height:'35px', + margin:"5px 0" + }, + on: { + click: () => { + console.log("selectedFlow",selectedFlow) + let target = this.$router.resolve({ + path: "/flow/detail", + query: { + module_id: selectedFlow.custom_model_id, + flow_id: selectedFlow.id, + isSinglePage: 1, + }, + }) + this.modalRender = (h) => + h("iframe", { + attrs: { + src: target.href, + }, + style: { + border: "none", + width: "100%", + height: "100%", + }, + }); + this.isShowModal = true; + this.$refs[`relation-flow-${info.name}`]?.blur() + } + } }, [ - h("span", {},option.title), - h("el-button", { + h("span", { style: { - float: 'right' + color:'blue' }, - props: { - type: 'primary', - size: 'mini', - icon: 'el-icon-search' + }, selectedFlow.title), + h("i", { + class: "el-icon-close", + style: { + fontSize: "12px", + cursor: "pointer", + marginLeft: "4px" }, on: { - click: e => { - e.stopPropagation() - let target = this.$router.resolve({ - path: "/flow/detail", - query: { - module_id: option.custom_model_id, - flow_id: option.id, - isSinglePage: 1, - }, - }); - this.modalRender = (h) => - h("iframe", { - attrs: { - src: target.href, - }, - style: { - border: "none", - width: "100%", - height: "100%", - }, - }); - this.isShowModal = true; - this.$refs[`relation-flow-${info.name}`]?.blur() + click: (e) => { + e.stopPropagation(); + const currentValue = target[info.name] ? target[info.name].toString().split(",").map(Number) : []; + const newValue = currentValue.filter(v => v !== Number(id)); + this.$set(target, info.name, newValue.toString()); + console.log("newValue",newValue,target[info.name] ? target[info.name].toString()?.split(",").map(Number) : []) } } - }, '查看') - ]) - ]) - ) - ); + }) + ]); + }) : []) + ]); break; case "relation": formItem = h( diff --git a/src/views/attendance/components/addYearHoliday.vue b/src/views/attendance/components/addYearHoliday.vue new file mode 100644 index 0000000..24d4ff0 --- /dev/null +++ b/src/views/attendance/components/addYearHoliday.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/views/attendance/yearHoliday.vue b/src/views/attendance/yearHoliday.vue new file mode 100644 index 0000000..20abedc --- /dev/null +++ b/src/views/attendance/yearHoliday.vue @@ -0,0 +1,266 @@ + + + + +