diff --git a/src/components/XyTable/index.vue b/src/components/XyTable/index.vue index 98e3806..78d5717 100644 --- a/src/components/XyTable/index.vue +++ b/src/components/XyTable/index.vue @@ -241,6 +241,7 @@ export default { .then((res) => { this.listData = this.getByStrkey(res.data, this.resProp); this.totalData = res.data.total; + this.$emit('loaded') setTimeout(() => { this.loading = false; @@ -260,6 +261,7 @@ export default { .then((res) => { this.listData = this.getByStrkey(res, this.resProp); this.totalData = res.total; + this.$emit('loaded') setTimeout(() => { this.loading = false; @@ -367,7 +369,7 @@ export default { this.$refs.table.toggleRowExpansion(row, expanded); }, setCurrentRow(row) { - this.$refs.table.toggleRowExpansion(row); + this.$refs.table.setCurrentRow(row); }, clearSort() { this.$refs.table.clearSort(); @@ -384,6 +386,9 @@ export default { getSelection(){ return this.$refs.table?.store?.states?.selection ?? [] }, + getListData () { + return this.listData + }, //table通讯事件 delete(row, type) { @@ -443,6 +448,7 @@ export default { expandChange(row, expanded) { this.$emit("expand-change", row, expanded); }, + deleteClick(row) { this.$emit("delete", row); if (this.destroyAction) { @@ -926,6 +932,7 @@ export default { .xy-table__page { display: flex; justify-content: right; + align-items: center; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background: rgba(140, 140, 140, 0.6); diff --git a/src/utils/createDialog.js b/src/utils/createDialog.js index 629a154..24c9d46 100644 --- a/src/utils/createDialog.js +++ b/src/utils/createDialog.js @@ -1,12 +1,12 @@ -import { domMap } from '@/const/inputType' -import { addPropsMap } from '@/const/addProps' +import { domMap } from "@/const/inputType"; +import { addPropsMap } from "@/const/addProps"; export class CreateDialog { - replaces - self - $createElement - options - constructor (self, replaces = [], options) { + replaces; + self; + $createElement; + options; + constructor(self, replaces = [], options) { /* replace = [ { @@ -16,24 +16,24 @@ export class CreateDialog { } ] */ - this.self = self - this.$createElement = self.$createElement - this.replaces = replaces - this.options = options + this.self = self; + this.$createElement = self.$createElement; + this.replaces = replaces; + this.options = options; } - getEventType (info) { + getEventType(info) { if (info === "checkbox") { return "change"; } return "input"; } fileRemoveHandler(file, field) { - let that = this.self + 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 + extraProps(info) { + let that = this.self; let props = {}; if (info.edit_input === "file" || info.edit_input === "files") { props.fileList = that.file[info.field]; @@ -66,24 +66,24 @@ export class CreateDialog { return props; } optionsRender(h, info) { - let that = this.self + 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, - }, - }) - ) + 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") { @@ -128,16 +128,22 @@ export class CreateDialog { ]; } } - render () { - let that = this.self - const h = this.$createElement + render() { + let that = this.self; + const h = this.$createElement; return h( "el-dialog", { + class: "dialog", + ref: "dialog", props: { top: "8vh", - title: "新增", + title: that.title + ? that.title + : that.type === "add" + ? "新增" + : "编辑", visible: that.dialogVisible, width: this.options?.width ? this.options.width : "800px", }, @@ -177,154 +183,151 @@ export class CreateDialog { (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, - }, + let replace = this.replaces.find((j) => j.key === i.field); + + dom.push( + h( + "el-form-item", + { + ref: `elFormItem${i.field}`, + style: { + width: "100%", }, - 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 - ); - } - }, + props: { + label: i.name, + prop: i.field, + required: + i.validation instanceof Array + ? !!i.validation.find((i) => i === "required") + : false, + }, + }, + replace && replace.render + ? [replace.render] + : [ + 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], + readonly: that.type === "show", + //disabled: that.type === 'show', + }, + 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", { + }, + 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: { - "el-icon-circle-check": + "uploaded-a": 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", - }, + padding: "0 4px", }, - file.name - ), - ]), - h("i", { - class: "el-icon-close", - on: { - ["click"]: () => - this.fileRemoveHandler( - file, - i.field - ), }, - }), - ]; - }, - } - : "", - }, - this.optionsRender(h, i) - ), - ] - ) - ); - } + 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) + 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, + dom.push( + h( + "el-form-item", + { + ref: `elFormItem${replace.key}`, + style: { + width: "100%", + ...replace.rowStyle, + }, + props: { + label: replace.label, + prop: replace.key, + }, }, - }, - [replace.render] - )) + [replace.render] + ) + ); } else { - dom.push(replace.render) + dom.push(replace.render); } - } - }) + }); return dom; })() ), @@ -335,7 +338,7 @@ export class CreateDialog { "el-button", { props: { - size: "mini" + size: "mini", }, on: { click: () => (that.dialogVisible = false), @@ -349,7 +352,7 @@ export class CreateDialog { props: { type: "warning", plain: true, - size: 'mini' + size: "mini", }, on: { click: () => that.init(), @@ -362,7 +365,7 @@ export class CreateDialog { { props: { type: "primary", - size: 'mini' + size: "mini", }, on: { click: that.submit, diff --git a/src/views/assets/component/addHistory.vue b/src/views/assets/component/addHistory.vue index 383bd33..db722eb 100644 --- a/src/views/assets/component/addHistory.vue +++ b/src/views/assets/component/addHistory.vue @@ -16,17 +16,17 @@ export default { }, { key: 'houseArea', - label: '房产日期', + label: '日期', render: h('span', this.row.dengjishijian) }, { key: 'tudixingzhi', label: '土地性质', - render: h('span','') + render: h('span', this.row.shiyongquanleixing) }, { key: 'tudiyongtu', - label: '土地/房产用途', + label: '用途', render: h('span', this.row.yongtu) } ],{ @@ -36,6 +36,7 @@ export default { }, data() { return { + columns: 1, row: {}, formInfo: [], id: "", @@ -68,7 +69,7 @@ export default { this.dialogVisible = false; }, setType(type = "add") { - let types = ["add", "editor"]; + let types = ["add", "editor", "show"]; if (types.includes(type)) { this.type = type; } else { @@ -84,7 +85,7 @@ export default { }, async getDetail() { - const res = await show({ id: this.id, table_name: this.tableName }); + const res = await show({ id: this.row.id_his_evolutions_house_id_relation?.id || this.row.id_his_evolutions_land_id_relation?.id, table_name: 'his_evolutions' }); this.$integrateData(this.form, res); this.formInfo.forEach((i) => { @@ -115,10 +116,42 @@ export default { }, submit() { - console.log(this.form) + if (/\/house/g.test(this.$route.path)) { + this.form['house_id'] = this.row.id + } + if (/\/land/g.test(this.$route.path)) { + this.form['land_id'] = this.row.id + } + if (this.type === "add") { + if (this.form.hasOwnProperty("id")) { + delete this.form.id; + } + } + if (this.type === "editor") { + Object.defineProperty(this.form, "id", { + value: this.id, + enumerable: true, + configurable: true, + writable: true, + }); + } + + save(Object.assign(this.form, { table_name: 'his_evolutions' })).then(res => { + this.$Message.success({ + content: `${this.type === "add" ? "新增" : "编辑"}成功`, + }); + this.$emit("refresh"); + this.hidden(); + }) }, }, - computed: {}, + computed: { + title () { + if (this.type === 'add') return '新增' + if (this.type === 'editor') return '编辑' + if (this.type === 'show') return '查看' + } + }, watch: { formInfo: { handler: function (newVal) { @@ -152,16 +185,17 @@ export default { } }); - document.documentElement.style.setProperty( - "--column-num", - newVal.length > 11 ? '2' : '1' - ); + this.columns = newVal.length > 11 ? '2' : '1' }, //immediate: true, }, dialogVisible(val) { if (val) { - if (this.type === "editor") { + document.documentElement.style.setProperty( + "--column-num", + this.columns + ); + if (this.type === "editor" || this.type === "show") { this.$nextTick(() => this.getDetail()); } } else { diff --git a/src/views/assets/component/addHouse.vue b/src/views/assets/component/addHouse.vue index b364efd..84feaae 100644 --- a/src/views/assets/component/addHouse.vue +++ b/src/views/assets/component/addHouse.vue @@ -19,6 +19,7 @@ export default { }, data() { return { + columns: 1, id: "", type: "add", dialogVisible: false, @@ -253,15 +254,16 @@ export default { } }); - document.documentElement.style.setProperty( - "--column-num", - newVal.length > 11 ? '2' : '1' - ); + this.columns = newVal.length > 11 ? '2' : '1' }, //immediate: true, }, dialogVisible(val) { if (val) { + document.documentElement.style.setProperty( + "--column-num", + this.columns + ); if (this.type === "editor") { this.$nextTick(() => this.getDetail()); } diff --git a/src/views/assets/component/addLand.vue b/src/views/assets/component/addLand.vue index 098796b..4f31e4b 100644 --- a/src/views/assets/component/addLand.vue +++ b/src/views/assets/component/addLand.vue @@ -1,6 +1,6 @@ - -