diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index 8bdecbc..63fd679 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -21,7 +21,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab //下拉选项 let options = []; if (info?.selection_model) { - options = info.selection_model_items; + options = info.selection_model_items || []; } else if (info?.stub) { options = info?.stub?.split(/\r\n/) || []; } @@ -36,7 +36,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab case "text": formItem = h(formBuilderMap(device).get(info.type), { props: { - value: row ? row[info.name] : this.form[info.name], + value: target[info.name], clearable: true, placeholder: info.help_text, }, @@ -45,9 +45,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, on: { input: (e) => { - row - ? this.$set(row, info.name, e) - : this.$set(this.form, info.name, e); + this.$set(target, info.name, e) }, }, }); @@ -59,7 +57,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab autosize: { minRows: 2, }, - value: row ? row[info.name] : this.form[info.name], + value: target[info.name], clearable: true, placeholder: info.help_text, }, @@ -68,9 +66,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, on: { input: (e) => { - row - ? this.$set(row, info.name, e) - : this.$set(this.form, info.name, e); + this.$set(target, info.name, e) }, }, }); @@ -81,7 +77,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab type: "date", "value-format": "yyyy-MM-dd", format: "yyyy年MM月dd日", - value: row ? row[info.name] : this.form[info.name], + value: target[info.name], clearable: true, placeholder: info.help_text, "picker-options": { @@ -148,9 +144,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, on: { input: (e) => { - row - ? this.$set(row, info.name, e) - : this.$set(this.form, info.name, e); + this.$set(target, info.name, e) }, }, }); @@ -161,7 +155,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab type: "datetime", "value-format": "yyyy-MM-dd HH:mm:ss", format: this.datetimeFormat, - value: row ? row[info.name] : this.form[info.name], + value: target[info.name], clearable: true, placeholder: info.help_text, "picker-options": { @@ -176,19 +170,18 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, on: { input: (e) => { - row - ? this.$set(row, info.name, e) - : this.$set(this.form, info.name, e); + this.$set(target, info.name, e) }, }, }); break; + case "choice": case "select": const getSelectValue = () => { if (!!info.multiple) { return target[info.name] ? target[info.name].toString()?.split(/,|\|/).map(i => isNaN(Number(i)) ? i : Number(i)) : [] } else { - return target[info.name] + return isNaN(Number(target[info.name])) ? target[info.name] : Number(target[info.name]) } } formItem = h( @@ -202,6 +195,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab 'multiple-limit': info.multiple, 'collapse-tags': true, filterable: true, + 'value-key': 'id', 'allow-create': !!info.is_select2_tag, 'default-first-option': true }, @@ -219,6 +213,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, options.map((option) => h("el-option", { + key: typeof option === "object" ? option.id : option, props: { label: typeof option === "object" ? option.name : option, value: typeof option === "object" ? option.id : option, @@ -232,16 +227,14 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab formBuilderMap(device).get(info.type), { props: { - value: row ? row[info.name] : this.form[info.name], + value: target[info.name], }, attrs: { placeholder: info.help_text, }, on: { input: (e) => { - row - ? this.$set(row, info.name, e) - : this.$set(this.form, info.name, e); + this.$set(target, info.name, e) }, }, }, @@ -321,12 +314,12 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab "application/msword,image/jpeg,application/pdf,image/png,application/vnd.ms-powerpoint,text/plain,application/x-zip-compressed,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", multiple: !!info.multiple, limit: info.multiple ? 20 : 1, - fileList: this.form[info.name]?.map(i => { + fileList: this.form[info.name] instanceof Array ? this.form[info.name]?.map(i => { if (i.hasOwnProperty('original_name')) { i.name = i.original_name } return i - }), + }) : [], beforeUpload: (file) => { if (file.size > uploadSize) { this.$message({ @@ -445,7 +438,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab type: "primary", }, attrs: { - href: row ? row[info.name] : this.form[info.name], + href: target[info.name], target: "_blank", }, }, @@ -455,77 +448,6 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab case "hr": formItem = h(formBuilderMap(device).get(info.type), {}, info.label); break; - case "choice": - formItem = h( - formBuilderMap(device).get(info.type), - { - props: { - value: row ? (row[info.name] ? row[info.name].toString()?.split(/,|\|/).map(i => isNaN(Number(i)) ? i : Number(i)) : []) : (this.form[info.name] ? this.form[info.name].toString()?.split(/,|\|/).map(i => Number(i)) : []), - clearable: true, - placeholder: info.help_text, - multiple: !!info.multiple, - 'multiple-limit': info.multiple, - filterable: true - }, - attrs: { - placeholder: info.help_text, - }, - style: { - width: "100%", - }, - on: { - input: (e) => { - row - ? this.$set(row, info.name, e.toString()) - : this.$set(this.form, info.name, e.toString()); - }, - }, - }, - options.map((option) => - h("el-option", { - props: { - label: typeof option === "object" ? option.name : option, - value: typeof option === "object" ? option.id : option, - }, - }) - ) - ); - break; - case "choices": - formItem = h( - formBuilderMap(device).get(info.type), - { - props: { - value: row ? (row[info.name] ? row[info.name].toString()?.split(/,|\|/).map(i => isNaN(Number(i)) ? i : Number(i)) : []) : (this.form[info.name] ? this.form[info.name].toString()?.split(/,|\|/).map(i => isNaN(Number(i)) ? i : Number(i)) : []), - clearable: true, - placeholder: info.help_text, - multiple: true, - filterable: true - }, - attrs: { - placeholder: info.help_text, - }, - style: { - width: '100%' - }, - on: { - input: (e) => { - row - ? this.$set(row, info.name, e.toString()) - : this.$set(this.form, info.name, e.toString()); - }, - }, - }, - options.map((option) => - h("el-option", { - props: { - label: option, - value: option, - }, - }) - ) - ); - break; case "relation-flow": if (!this.flows[info.name]) { flowList('all', { @@ -542,7 +464,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab formBuilderMap(device).get(info.type), { props: { - value: row ? (row[info.name] ? row[info.name].toString()?.split(',').map(i => Number(i)) : []) : (this.form[info.name] ? this.form[info.name].toString()?.split(',').map(i => Number(i)) : []), + value: (target[info.name] ? target[info.name].toString()?.split(',').map(i => Number(i)) : []), clearable: true, placeholder: info.help_text, multiple: true, @@ -558,9 +480,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, on: { input: (e) => { - row - ? this.$set(row, info.name, e.toString()) - : this.$set(this.form, info.name, e.toString()); + this.$set(target, info.name, e.toString()) } }, }, @@ -742,13 +662,14 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab target[info.name] ? moment(target[info.name]).format("YYYY年MM月DD日 HH时mm分") : '' ); break; + case "choice": case "select": const getDetailSelectValue = () => { let res = '' if (!!info.multiple) { res = target[info.name] ? target[info.name].toString()?.split(/,|\|/).map(i => isNaN(Number(i)) ? i : Number(i)) : [] } else { - res = target[info.name] + res = isNaN(Number(target[info.name])) ? target[info.name] : Number(target[info.name]) } if (res instanceof Array) { return options?.filter((i) => @@ -757,14 +678,13 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab : res.indexOf(i) !== -1 )?.map(i => typeof i === 'object' ? i.name : i)?.toString() } else { - return res + return options?.filter((i) => + typeof i === "object" + ? res === i.id + : res === i + )?.map(i => typeof i === 'object' ? i.name : i)?.toString() } } - let findValue = options.find((i) => - typeof i === "object" - ? i.id == target[info.name] - : i === target[info.name] - ); formItem = h( "span", { @@ -775,41 +695,6 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab getDetailSelectValue() ); break; - case "choice": - formItem = h( - "span", - { - style: { - color: "#333", - }, - }, - target[info.name]?.toString()?.split(/,|\|/).map(j => { - return options.find((i) => i.id == j)?.name; - })?.toString() - ); - break; - case "choices": - let findChoicesValue = options.find((i) => - typeof i === "object" - ? i.id == target[info.name] - : i === target[info.name] - ); - formItem = h( - "span", - { - style: { - color: "#333", - }, - }, - info.multiple ? target[info.name]?.toString()?.split(/,|\|/).map(j => { - return options.find((i) => - typeof i === "object" - ? i.id == j - : i === j - )?.name; - })?.toString() : typeof findChoicesValue === "object" ? findChoicesValue.name : findChoicesValue - ); - break; case "relation-flow": if (!this.flows[info.name]) { flowList('all', { @@ -868,7 +753,6 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ); break; case "file": - console.log(row ? row[info.name] : '') formItem = row ? h( 'vxe-upload', diff --git a/src/views/attendance/index.vue b/src/views/attendance/index.vue index a8901c7..465daa0 100644 --- a/src/views/attendance/index.vue +++ b/src/views/attendance/index.vue @@ -15,8 +15,10 @@
ip打卡
-
当前距离:{{ nowDistance }}千米
-
最大打卡范围:{{ maxDistance }}千米
+
+
当前距离:{{ nowDistance }}千米
+
最大打卡范围:{{ maxDistance }}千米
+
@@ -95,6 +97,7 @@ export default { remark: '', // end isIpSign: true, + ipSignMsg: '', isGetLocation: false, isOutSign: false, pos: { @@ -396,7 +399,8 @@ export default { }, mounted() { this.getMyDuty() - this.isAuthPermission() + this.preIp() + // this.isAuthPermission() }, created() { window.getAppLocation = this.getAppLocation diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index b8f4739..49fed15 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -258,6 +258,16 @@ +
@@ -356,6 +366,12 @@ export default { noticeTimer: null, noticeLoading: false, notice: [], + noticeSelect: { + page: 1, + page_size: 20, + from: window.MODULE_NAME || process.env.VUE_APP_MODULE_NAME, + }, + noticeTotal: 0, noticeTable: [ { title: "下发时间", @@ -493,15 +509,12 @@ export default { headers: { Authorization: `Bearer ${getToken()}`, }, - params: { - page: 1, - page_size: 30, - from: window.MODULE_NAME || process.env.VUE_APP_MODULE_NAME, - }, + params: this.noticeSelect, } ); if (res.status === 200) { - this.notice = res.data.data?.data; + this.notice = res.data.data?.result; + this.noticeTotal = res.data.data?.total; } this.noticeLoading = false; } catch (err) { diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index 12ca0de..5a647cb 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -19,6 +19,7 @@ @@ -73,10 +72,9 @@ :fields="fields" :original-form="form" :readable="readableFields" - :script-content="scriptContent" :writeable="writeableFields" - :rules="rules" - :sub-rules="subRules" + :rules="{}" + :sub-rules="{}" :logs="config.logs" > @@ -482,8 +480,7 @@ export default { spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.8)", }); - // 路由为detail为详情 - if (/\/detail/.test(this.$route.path) && this.$route.query.flow_id) { + if (this.$route.query.flow_id) { try { const res = await view(this.$route.query.flow_id); const { fields } = res?.customModel; @@ -551,104 +548,6 @@ export default { this.$message.error("配置失败"); loading.close(); } - } else if (!this.$route.query.flow_id) { - // 新建 - try { - this.csrf_token = generateRandomString() - const res = await preConfig(this.$route.query.module_id); - const { fields } = res?.customModel; - let subFormRequest = []; - const getSubForm = (id) => { - subFormRequest.push(fieldConfig(id)); - }; - fields.forEach((field) => { - if (field.sub_custom_model_id) { - getSubForm(field.sub_custom_model_id); - } - }); - const subConfigs = await Promise.all(subFormRequest); - subConfigs.forEach((sub) => { - if (sub.customModel?.id) { - this.subConfig.set(sub.customModel?.id, sub); - } - }); - this.config = res; - this.generateForm(this.form, fields); - this.handleDefaultJSON(); - this.form = Object.assign({}, this.form); - loading.close(); - } catch (err) { - console.error(err); - this.$message.error("配置失败"); - loading.close(); - } - } else { - // 待办 - try { - const res = await preDeal(this.$route.query.flow_id); - const { fields } = res?.customModel; - let subFormRequest = []; - const getSubForm = (id) => { - subFormRequest.push(fieldConfig(id)); - }; - fields.forEach((field) => { - if (field.sub_custom_model_id) { - getSubForm(field.sub_custom_model_id); - } - }); - const subConfigs = await Promise.all(subFormRequest); - subConfigs.forEach((sub) => { - if (sub.customModel?.id) { - this.subConfig.set(sub.customModel?.id, sub); - } - }); - this.config = res; - this.generateForm(this.form, fields); - this.handleDefaultJSON(); - const { data } = res?.flow; - for (let key in data) { - try { - let jsonObj = JSON.parse(data[key]); - jsonObj.forEach(item => { - // 遍历对象中的每个键值对 - for (const key in item) { - if (typeof item[key] === 'string') { - try { - // 尝试解析字符串为 JSON 对象 - const parsedValue = JSON.parse(item[key]); - // 如果解析成功,替换原始字符串 - item[key] = parsedValue; - } catch (e) { - // 如果解析失败,继续保持原始字符串 - } - } - } - }) - if (this.form.hasOwnProperty(key)) { - this.form[key] = jsonObj; - } - } catch (err) { - if (this.form.hasOwnProperty(key)) { - if (data[key] instanceof Array) { - if (data[key].length > 0) { - this.form[key] = data[key]; - } else { - this.form[key] = '' - } - } - if (data[key] && data[key] !== 'null' && data[key] !== 'undefined') { - this.form[key] = data[key]; - } - } - } - } - this.form = Object.assign({}, this.form); - loading.close(); - } catch (err) { - console.error(err); - this.$message.error("配置失败"); - loading.close(); - } } }, @@ -706,7 +605,6 @@ export default { delete copyForm[key] } } - copyForm["current_node_id"] = this.config.currentNode.id; try { if (this.$route.query.flow_id) { copyForm.id = this.$route.query.flow_id; @@ -715,6 +613,7 @@ export default { copyForm ); this.result = flow; + this.$message.success("操作成功") } } catch (err) { console.error(err); @@ -755,7 +654,7 @@ export default { : this.config?.currentNode?.readable || []; }, writeableFields() { - return this.config?.currentNode?.writeable || []; + return this.fields?.map(i => i.id) || []; }, node() { return this.config?.currentNode || {};