diff --git a/src/utils/formBuilder.js b/src/utils/formBuilder.js index cc49d9d..8acc4c0 100644 --- a/src/utils/formBuilder.js +++ b/src/utils/formBuilder.js @@ -277,8 +277,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab row[info.name].push({ response: response.data.data, name: response.data.data.original_name, - url: response.data.data.url, - TYPE_FILE: 1 + url: response.data.data.url }) } else { this.$message.error("上传失败") @@ -316,22 +315,13 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab file.response = file.response.data; } }); - this.form[info.name] = fileList.map(i => ({ - ...i, - TYPE_FILE: 1 - })); + this.form[info.name] = fileList }, onRemove: (file, fileList) => { - this.form[info.name] = fileList.map(i => ({ - ...i, - TYPE_FILE: 1 - })); + this.form[info.name] = fileList }, onError: (err, file, fileList) => { - this.form[info.name] = fileList.map(i => ({ - ...i, - TYPE_FILE: 1 - })); + this.form[info.name] = fileList this.$message({ type: "warning", message: err, @@ -905,21 +895,21 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, [formItem,(() => { if (info.is_sign) { - let log = this.logs.find(log => log.node?.fields?.findIndex(field => field?.field?.name === info.name) !== -1) - if (log) { + let log = this.logs.find(log => log.node?.fields?.findIndex(field => field?.field?.name === info.name) !== -1) && (row ? row[info.name] : this.form[info.name]) + if (log && log.user) { return h('div',[ h('el-image',{ style: { 'max-height': '80px' }, props: { - src: log.user.sign_file?.url, + src: log.user?.sign_file?.url, fit: 'contain', - alt: log.user.sign_id + alt: log.user?.sign_id }, attrs: { - src: log.user.sign_file?.url, - alt: log.user.sign_id + src: log.user?.sign_file?.url, + alt: log.user?.sign_id } }) ]) @@ -930,11 +920,6 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab } } if (device === "mobile") { - let findValue = options?.find((i) => - typeof i === "object" - ? i.id === (row ? row[info.name] : this.form[info.name]) - : i === (row ? row[info.name] : this.form[info.name]) - ); if (info._writeable || pWrite) { switch (info.type) { case "text": @@ -1024,13 +1009,18 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }); break; case "select": + let findSelect = options?.find((i) => + typeof i === "object" + ? i.id === (row ? row[info.name] : this.form[info.name]) + : i === (row ? row[info.name] : this.form[info.name]) + ); formItem = h("van-field", { props: { readonly: true, clickable: true, name: info.name, label: info.label, - value: typeof findValue === "object" ? findValue.name : findValue, + value: typeof findSelect === "object" ? findSelect.name : findSelect, clearable: true, placeholder: info.help_text, }, @@ -1045,13 +1035,22 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }); break; case "choice": + let findChoice = info.multiple ? options?.filter((i) => + typeof i === "object" + ? (row ? row[info.name].indexOf(i.id) !== -1 : this.form[info.name].indexOf(i.id) !== -1) + : i === (row ? row[info.name] : this.form[info.name]) + ) : options?.find((i) => + typeof i === "object" + ? i.id === (row ? row[info.name] : this.form[info.name]) + : i === (row ? row[info.name] : this.form[info.name]) + ); formItem = h("van-field", { props: { readonly: true, clickable: true, name: info.name, label: info.label, - value: typeof findValue === "object" ? findValue.name : findValue, + value: (findChoice instanceof Array) ? (findChoice.map(i => typeof i === "object" ? i.name : i).toString()) : (typeof findChoice === "object" ? findChoice.name : findChoice), clearable: true, placeholder: info.help_text, }, @@ -1190,13 +1189,18 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ]) break; case 'relation-flow': + let findFlow = options?.find((i) => + typeof i === "object" + ? i.id === (row ? row[info.name] : this.form[info.name]) + : i === (row ? row[info.name] : this.form[info.name]) + ); formItem = h("van-field", { props: { readonly: true, clickable: true, name: info.name, label: info.label, - value: typeof findValue === "object" ? (findValue.name || findValue.title) : findValue, + value: typeof findFlow === "object" ? (findFlow.name || findFlow.title) : findFlow, clearable: true, placeholder: info.help_text, }, @@ -1327,7 +1331,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab ); break; case "select": - let findValue = options.find((i) => + let findSelect = options.find((i) => typeof i === "object" ? i.id === this.form[info.name] : i === this.form[info.name] @@ -1340,12 +1344,32 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }, props: { title: info.label, - value: typeof findValue === "object" ? findValue.name : findValue + value: typeof findSelect === "object" ? findSelect.name : findSelect + } + }, + ); + break; + case 'choice': + let findChoice = options.find((i) => + typeof i === "object" + ? i.id === this.form[info.name] + : i === this.form[info.name] + ); + formItem = h( + "van-cell", + { + attrs: { + for: info.name + }, + props: { + title: info.label, + value: typeof findChoice === "object" ? findChoice.name : findChoice } }, ); break; case 'file': + let files = (row ? row[info.name] : this.form[info.name]) formItem = h( "van-cell", { @@ -1356,12 +1380,11 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab title: info.label, } }, - (row ? row[info.name] : this.form[info.name]).map(file => h("div", {}, [ + ((files && files !== 'null' && files !== 'undefined') ? files : [])?.map(file => h("div", {}, [ h( "a", { attrs: { - href: file.url, download: file.name, }, class: { @@ -1370,6 +1393,11 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab style: { padding: "0 4px", }, + on: { + click:_ => { + this.$bus.$emit('online-file', file.url) + } + } }, file.name ), @@ -1386,7 +1414,7 @@ export default function formBuilder(device, info, h, row, pWrite = false,pReadab }), h( "div", - this.form[info.name].map((sForm, sIndex) => + this.form[info.name]?.map((sForm, sIndex) => h( "van-cell-group", { diff --git a/src/views/VehicleCertificate/index.vue b/src/views/VehicleCertificate/index.vue index adfda81..d9711be 100644 --- a/src/views/VehicleCertificate/index.vue +++ b/src/views/VehicleCertificate/index.vue @@ -21,10 +21,31 @@ :data="tableData" > + - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -66,6 +87,8 @@ import { index as vehicleIndex } from '@/api/vehicle' import { deepCopy } from '@/utils' import { index, save, destroy } from '@/api/vehicleCertificate' import AddVehicleCertificate from './components/AddVehicleCertificate.vue' +import axios from "axios"; +import {getToken} from "@/utils/auth"; export default { components: { AddVehicleCertificate @@ -112,6 +135,22 @@ export default { this.getList() }, methods: { + uploadMethod(file, row) { + const formData = new FormData() + formData.append('file', file) + return axios.post(process.env.VUE_APP_UPLOAD_API, formData, { + headers: { + Authorization: `Bearer ${getToken()}`, + } + }).then((response) => { + if (response.status === 200 && !response.data.code) { + row.renewed_id = response.data.data.id + row.renewed = response.data.data + } else { + this.$message.error("上传失败") + } + }) + }, editRowEvent(row) { if (this.$refs['table']) { this.$refs['table'].setEditRow(row) diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 5893281..ce2f316 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -171,24 +171,20 @@ - - - - - - - - - - - {{ item.name }} + @click="toCreate(item)"> + + + + + + + - + {{ item.name }} + @@ -287,6 +283,7 @@ import { getToken } from "@/utils/auth"; import { flow } from "@/api/flow"; import { index as configIndex } from "@/api/config"; import { index } from "@/api/attendance"; +import {isExternal} from "@/utils/validate"; export default { name: "Dashboard", components: { @@ -385,6 +382,23 @@ export default { } }, methods: { + toCreate(flow, cate) { + if(isExternal(flow.url)) { + const url = new URL(flow.url) + window.open(flow.url,'_blank') + } else if (flow.url) { + if (/\?.+/g.test(flow.url)) { + window.open(window.location.origin + flow.url,'_blank') + } + } else { + this.$router.push({ + path: '/flow/create', + query: { + module_id: flow.id + } + }) + } + }, getTodayAttendance(date,key = 'attendance') { let temp = this.attendanceData.attendances.find((i) => i.date === date) ?? {} return temp[key] @@ -737,15 +751,15 @@ $btn-colors: linear-gradient(90deg, #d4bbfd 0%, #af7bff 100%), grid-template-columns: repeat(4, 1fr); grid-gap: 20px; - + & > div { + cursor: pointer; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } & > * { - & > div { - cursor: pointer; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - } + @for $index from 1 through length($btn-colors) { &:nth-child(#{$index}n) .flow-cover { diff --git a/src/views/flow/MobileForm.vue b/src/views/flow/MobileForm.vue index 7be62bf..102ac79 100644 --- a/src/views/flow/MobileForm.vue +++ b/src/views/flow/MobileForm.vue @@ -47,13 +47,19 @@ export default { default: () => [], required: true }, - fileList: { + scriptContent: String, + rules: { type: Object, default: () => ({}), - required: true }, - scriptContent: String - + subRules: { + type: Object, + default: () => ({}), + }, + logs: { + type: Array, + default: () => [] + } }, data() { return { @@ -109,9 +115,6 @@ export default { originalForm(newVal) { this.form = deepCopy(newVal) }, - fileList(newVal) { - this.file = deepCopy(newVal) - }, scriptContent(newVal) { if(newVal) { try { @@ -133,6 +136,7 @@ export default { _readable: this.readable.indexOf(field.id) !== -1, _writeable: this.writeable.indexOf(field.id) !== -1 })) + const subFields = Array.from(this.subForm).map(i => i[1]?.customModel?.fields).filter(i => i).flat() return h('div',[ h('van-form',{ props: { @@ -140,10 +144,11 @@ export default { } },authFields.map(field => formBuilder.bind(this)(this.device, field, h))), //calendar - authFields.findIndex(i => i.type === 'date') !== -1 ? + (authFields.findIndex(i => i.type === 'date') !== -1 || subFields.findIndex(i => i.type === 'date')) ? h('van-calendar',{ ref: `vanCalendar`, props: { + position: 'bottom', value: this.vanCalendarOption.isShow, 'min-date': this.$moment().subtract('years',10).toDate(), 'max-date': this.$moment().add('years',10).toDate(), @@ -164,7 +169,7 @@ export default { } }) : '', //datetimepicker - authFields.findIndex(i => i.type === 'datetime') !== -1 ? + (authFields.findIndex(i => i.type === 'datetime') !== -1 || subFields.findIndex(i => i.type === 'datetime') !== -1) ? h('van-popup',{ props: { value: this.vanTimePickerOption.isShow, @@ -184,7 +189,6 @@ export default { on: { confirm: time => { if(typeof this.vanTimePickerOption.originalObj === 'object') { - console.log(this.vanTimePickerOption.originalObj) this.$set(this.vanTimePickerOption.originalObj,this.vanTimePickerOption.forFormName,moment(time).format('YYYY-MM-DD HH:mm:ss')) } else { this.$set(this.form,this.vanTimePickerOption.forFormName,moment(time).format('YYYY-MM-DD HH:mm:ss')) @@ -198,7 +202,7 @@ export default { }) ]) : '', //popup - authFields.findIndex(i => i.type === 'select') !== -1 ? + (authFields.findIndex(i => i.type === 'select') !== -1 || subFields.findIndex(i => i.type === 'select') !== -1) ? h('van-popup',{ props: { value: this.vanPopupOption.isShow, @@ -232,7 +236,7 @@ export default { }) ]) : '', // 多选 - authFields.findIndex(i => ['relation-flow','choice','choices'].indexOf(i.type) !== -1) !== -1 ? + (authFields.findIndex(i => ['relation-flow','choice','choices'].indexOf(i.type) !== -1) !== -1 || subFields.findIndex(i => ['relation-flow','choice','choices'].indexOf(i.type) !== -1) !== -1) ? h('van-popup',{ props: { value: this.multipleSelectOption.isShow, diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index 69aa5ee..dadc6a4 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -66,9 +66,11 @@ :fields="fields" :original-form="form" :readable="readableFields" - :file-list="fileList" :script-content="scriptContent" :writeable="writeableFields" + :rules="rules" + :sub-rules="subRules" + :logs="config.logs" > @@ -699,7 +701,7 @@ export default { keys.forEach(key => { if (form[key] instanceof Array) { if (form[key].length > 0) { - if (form[key][0].hasOwnProperty('TYPE_FILE') && form[key][0]['TYPE_FILE']) { + if (form[key][0].hasOwnProperty('response')) { form[key] = form[key].map(i => i.response) } else { form[key].forEach(i => { diff --git a/src/views/flow/index.vue b/src/views/flow/index.vue index d45f33c..e28d5d4 100644 --- a/src/views/flow/index.vue +++ b/src/views/flow/index.vue @@ -91,10 +91,10 @@ export default { toCreate(flow,cate) { if(isExternal(flow.url)) { const url = new URL(flow.url) - if (/\?.+/g.test(url.hash)) { - window.open(flow.url + `&auth_token=${getToken()}`,'_blank') - } else { - window.open(flow.url + `?auth_token=${getToken()}`,'_blank') + window.open(flow.url,'_blank') + } else if (flow.url) { + if (/\?.+/g.test(flow.url)) { + window.open(window.location.origin + flow.url,'_blank') } } else { this.$router.push({ diff --git a/src/views/flow/list.vue b/src/views/flow/list.vue index c15c6d7..50fc814 100644 --- a/src/views/flow/list.vue +++ b/src/views/flow/list.vue @@ -191,9 +191,59 @@ > - - - + + + + + + 办理 + 抄送 + 撤回 + 删除 + + + 查看 + + + + + + + 查看 - - - - - - - 办理 - 抄送 - 撤回 - 删除 - - 查看 - - + +