diff --git a/src/utils/createDialog.js b/src/utils/createDialog.js new file mode 100644 index 0000000..629a154 --- /dev/null +++ b/src/utils/createDialog.js @@ -0,0 +1,377 @@ +import { domMap } from '@/const/inputType' +import { addPropsMap } from '@/const/addProps' + +export class CreateDialog { + replaces + self + $createElement + options + constructor (self, replaces = [], options) { + /* + replace = [ + { + key: '', + label: '', + render: () => {} + } + ] + */ + this.self = self + this.$createElement = self.$createElement + this.replaces = replaces + this.options = options + } + getEventType (info) { + if (info === "checkbox") { + return "change"; + } + return "input"; + } + fileRemoveHandler(file, field) { + let that = this.self + that.file[field] = that.file[field].filter((item) => item !== file); + that.file = Object.assign({}, that.file); + } + extraProps (info) { + let that = this.self + let props = {}; + if (info.edit_input === "file" || info.edit_input === "files") { + props.fileList = that.file[info.field]; + props.beforeUpload = (file) => { + if (file.size / 1000 > 500) { + that.$message({ + type: "warning", + message: "上传图片大小超过500kb!", + }); + return false; + } + }; + + props.onSuccess = (response, file, fileList) => { + that.file[info.field] = fileList; + }; + + props.onRemove = (file, fileList) => { + that.file[info.field] = fileList; + }; + + props.onError = (err, file, fileList) => { + that.file[info.field] = fileList; + that.$message({ + type: "warning", + message: err, + }); + }; + } + return props; + } + optionsRender(h, info) { + let that = this.self + if (info.edit_input === "checkbox" || info.edit_input === "radio") { + return info._params && info._params instanceof Array + ? info._params.map((i) => + h("el-option", { + props: { + label: + i.name || + i.mingcheng || + i.label || + i.key || + i.value || + i.id || + i.no, + value: i.id || i.value, + }, + }) + ) + : []; + } + if (info.edit_input === "file" || info.edit_input === "files") { + return [ + h( + "el-button", + { + slot: "trigger", + props: { + size: "small", + type: "primary", + }, + }, + "选取文件" + ), + h( + "el-button", + { + style: { + "margin-left": "10px", + }, + props: { + size: "small", + type: "success", + }, + on: { + ["click"]: (e) => { + that.$refs[`elEdit_${info.field}`].submit(); + }, + }, + }, + "上传到服务器" + ), + h( + "div", + { + class: "el-upload__tip", + slot: "tip", + }, + "文件不超过500kb" + ), + ]; + } + } + render () { + let that = this.self + const h = this.$createElement + + return h( + "el-dialog", + { + props: { + top: "8vh", + title: "新增", + visible: that.dialogVisible, + width: this.options?.width ? this.options.width : "800px", + }, + on: { + "update:visible": (val) => { + that.dialogVisible = val; + }, + }, + }, + [ + h( + "el-scrollbar", + { + style: { + height: "58vh", + }, + }, + [ + h( + "el-form", + { + class: "form-body", + ref: "elForm", + style: { + "padding-right": "12px", + }, + props: { + model: that.form, + labelWidth: "80px", + rules: that.rules, + labelPosition: "right", + size: "small", + }, + }, + (() => { + let dom = []; + (this.options?.formInfo ? this.options.formInfo : that.formInfo) + .filter((i) => i.form_show) + .forEach((i, index) => { + let replace = this.replaces.find(j => j.key === i.field) + if (replace && replace.render) { + dom.push(replace.render) + } else { + dom.push( + h( + "el-form-item", + { + ref: `elFormItem${i.field}`, + style: { + width: "100%", + }, + props: { + label: i.name, + prop: i.field, + required: + i.validation instanceof Array + ? !!i.validation.find((i) => i === "required") + : false, + }, + }, + that.$scopedSlots[i.field] + ? that.$scopedSlots[i.field]({ + fieldInfo: i, + form: that.form, + file: that.file, + }) + : [ + h( + domMap.get(i.edit_input), + { + ref: `elEdit_${i.field}`, + style: { + width: "100%", + }, + props: { + ...addPropsMap.get(i.edit_input), + ...this.extraProps(i), + placeholder: i.help, + value: that.form[i.field], + }, + attrs: { + placeholder: i.help || `请填写${i.name}`, + }, + on: { + [this.getEventType(i.edit_input)]: ( + e + ) => { + if (i.field) { + that.form[i.field] = e; + that.form = Object.assign( + {}, + that.form + ); + } + }, + }, + scopedSlots: + i.edit_input === "file" || + i.edit_input === "files" + ? { + file: (scope) => { + let { file } = scope; + return [ + h("div", {}, [ + h("i", { + class: { + "el-icon-circle-check": + file.status === + "success", + "el-icon-loading": + file.status === + "uploading", + }, + style: { + color: + file.status === + "success" + ? "green" + : "", + }, + }), + h( + "a", + { + attrs: { + href: file.url, + download: file.name, + }, + class: { + "uploaded-a": + file.status === + "success", + }, + style: { + padding: "0 4px", + }, + }, + file.name + ), + ]), + h("i", { + class: "el-icon-close", + on: { + ["click"]: () => + this.fileRemoveHandler( + file, + i.field + ), + }, + }), + ]; + }, + } + : "", + }, + this.optionsRender(h, i) + ), + ] + ) + ); + } + }); + + this.replaces.forEach(replace => { + let info = that.formInfo.find(i => i.field === replace.key) + if (!info) { + if (replace.label) { + dom.push(h( + "el-form-item", + { + ref: `elFormItem${replace.key}`, + style: { + width: "100%", + }, + props: { + label: replace.label, + prop: replace.key, + }, + }, + [replace.render] + )) + } else { + dom.push(replace.render) + } + + } + }) + return dom; + })() + ), + ] + ), + h("template", { slot: "footer" }, [ + h( + "el-button", + { + props: { + size: "mini" + }, + on: { + click: () => (that.dialogVisible = false), + }, + }, + "取 消" + ), + h( + "el-button", + { + props: { + type: "warning", + plain: true, + size: 'mini' + }, + on: { + click: () => that.init(), + }, + }, + "重 置" + ), + h( + "el-button", + { + props: { + type: "primary", + size: 'mini' + }, + on: { + click: that.submit, + }, + }, + "确 定" + ), + ]), + ] + ); + } +} diff --git a/src/utils/createTable.js b/src/utils/createTable.js new file mode 100644 index 0000000..f1cc9f1 --- /dev/null +++ b/src/utils/createTable.js @@ -0,0 +1,74 @@ +import { show } from "@/api/system/customForm"; +import { listdept } from "@/api/system/department"; +import { getparameter } from "@/api/system/dictionary"; + +export async function resolveFormInfo(customFormId) { + const res = await show({ id: customFormId }, false); + + //字段处理 + //初始表白名单 + let baseTable = new Map([ + [ + "departments", + async () => { + const res = await listdept(); + return res; + }, + ], + ["admins", []], + ]); + let { fields, relation } = res; + let fieldRes = fields.sort((a, b) => a.sort - b.sort); + if ( + !fields || + !relation || + !fields instanceof Array || + !relation instanceof Array + ) { + throw new Error("fields或relation格式错误"); + } + fieldRes?.forEach((i, index) => { + i._relations = relation.find( + (j) => j.link_table_name.split("_")[1] === i.field + ); + if (i.select_item && typeof i.select_item === "object") { + let keys = Object.keys(i.select_item); + i._params = keys.map((key) => { + return { + key, + value: /^\d*$/.test(i.select_item[key]) + ? Number(i.select_item[key]) + : i.select_item[key], + }; + }); + } + if (i.edit_input === "file" || i.edit_input === "files") { + return; + } + if (i._relations) { + if (baseTable.get(i._relations.link_table_name)) { + baseTable + .get(i._relations.link_table_name)() + .then((res) => { + i._params = res.data; + }); + } else { + i._params = i._relations.parameter_id + ? getparameter({ id: i._relations.parameter_id }, false).then( + (res) => { + i._params = res.detail; + } + ) + : this.index({ + table_name: i._relations.link_table_name, + page: 1, + page_size: 9999, + }).then((res) => { + i._params = res.data; + }); + } + } + }); + + return fieldRes; +} diff --git a/src/views/assets/component/addHistory.vue b/src/views/assets/component/addHistory.vue new file mode 100644 index 0000000..383bd33 --- /dev/null +++ b/src/views/assets/component/addHistory.vue @@ -0,0 +1,207 @@ + + + + diff --git a/src/views/assets/component/addHouse.vue b/src/views/assets/component/addHouse.vue new file mode 100644 index 0000000..b364efd --- /dev/null +++ b/src/views/assets/component/addHouse.vue @@ -0,0 +1,305 @@ + + + + diff --git a/src/views/assets/component/addLand.vue b/src/views/assets/component/addLand.vue new file mode 100644 index 0000000..098796b --- /dev/null +++ b/src/views/assets/component/addLand.vue @@ -0,0 +1,314 @@ + + + + diff --git a/src/views/assets/house.vue b/src/views/assets/house.vue new file mode 100644 index 0000000..1d3cdfd --- /dev/null +++ b/src/views/assets/house.vue @@ -0,0 +1,667 @@ + + + + + diff --git a/src/views/assets/land.vue b/src/views/assets/land.vue new file mode 100644 index 0000000..a6e854a --- /dev/null +++ b/src/views/assets/land.vue @@ -0,0 +1,669 @@ + + + + + diff --git a/src/views/component/dialogTemplate.vue b/src/views/component/dialogTemplate.vue new file mode 100644 index 0000000..8a2af70 --- /dev/null +++ b/src/views/component/dialogTemplate.vue @@ -0,0 +1,302 @@ + + + + diff --git a/src/views/component/map.vue b/src/views/component/map.vue index a03776d..4277edb 100644 --- a/src/views/component/map.vue +++ b/src/views/component/map.vue @@ -482,6 +482,9 @@ export default { closeWhenClickMap: true, offset: new AMap.Pixel(-10, -10), }); + this.map.on('click',e => { + console.log(e) + }) }, // 加载 areaBG(adcode = ["320200"]) { @@ -513,6 +516,9 @@ export default { fillColor: "#3579c788", strokeColor: "#3579c7", }); + polygon.on('click',e => { + console.log('polygon',e) + }) this.polygons.push(polygon); this.map.setFitView(polygon); }