diff --git a/src/assets/scss/modules/management/form-main.scss b/src/assets/scss/modules/management/form-main.scss index 6e0cfa6fa..60f243942 100644 --- a/src/assets/scss/modules/management/form-main.scss +++ b/src/assets/scss/modules/management/form-main.scss @@ -21,6 +21,18 @@ .list_item_width_2 { width: 135px; } + + .list_item_width_3 { + width: 185px; + } + + + .item_width_5{ + width: 320px; + } + .item_width_6{ + width: 404px; + } } @@ -51,7 +63,14 @@ } } +.form_flex{ + display:flex; + justify-content: space-around; + .form_item{ +width:50%; + } +} .twoline { display: -webkit-box; diff --git a/src/assets/scss/modules/management/list-main.scss b/src/assets/scss/modules/management/list-main.scss index 922bfaf71..c752e60c4 100644 --- a/src/assets/scss/modules/management/list-main.scss +++ b/src/assets/scss/modules/management/list-main.scss @@ -19,6 +19,9 @@ .item_width_1{ width: 260px; } + .item_width_3{ + width: 200px; + } .item_width_2{ width: 160px; } diff --git a/src/utils/cascader.js b/src/utils/cascader.js new file mode 100644 index 000000000..3ab33ae07 --- /dev/null +++ b/src/utils/cascader.js @@ -0,0 +1,36 @@ +export function getItemByIdInCascader(arr, vals, idName, childName) { + let item = arr.find((v) => v[idName] == vals[0]); + if (vals.length > 1) { + return [ + item, + ...getItemByIdInCascader( + item[childName], + vals.slice(1), + idName, + childName + ), + ]; + } else { + return [item]; + } +} + +export function collapse(arr, childName) { + if (arr.length > 0) { + let ret = [...arr]; + arr.forEach((element) => { + let childs = element[childName]; + if (childs && Array.isArray(childs)) { + ret.push(...collapse(childs, childName)); + } + }); + return ret; + } else { + return []; + } +} + +export default { + getItemByIdInCascader, + collapse, +}; diff --git a/src/views/modules/base/collect.vue b/src/views/modules/base/collect.vue index bd19c5e0a..3d6cdb81a 100644 --- a/src/views/modules/base/collect.vue +++ b/src/views/modules/base/collect.vue @@ -110,7 +110,7 @@ prop="houseType" align="center" width="100" - label="自有/租住" + label="房屋状态" > - - -
- - - - - - @@ -303,6 +323,7 @@ import { requestPost } from "@/js/dai/request"; import nextTick from "dai-js/tools/nextTick"; import Schema from "async-validator"; +import Tinymce from "@c/tinymce2/index.vue"; var map; var search; @@ -311,6 +332,8 @@ var infoWindowList; var geocoder; // 新建一个正逆地址解析类 export default { + components: { Tinymce }, + props: { formId: { type: String, @@ -361,6 +384,10 @@ export default { type: Object, default: () => ({}), }, + editConfig: { + type: Object, + default: () => ({}), + }, }, data() { @@ -373,9 +400,11 @@ export default { editParams1: [], editParams2: [], + + uploadUrl: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadqrcodeV2", + customerId: localStorage.getItem("customerId"), }; }, - components: {}, computed: {}, watch: { editParams: { @@ -406,19 +435,53 @@ export default { iniFmData() { const { editParams, fmData, editParamsDiv } = this; editParams.forEach((item, index) => { - fmData[item.keyName] = item.value || ""; + if (typeof item.value == "function") { + fmData[item.keyName] = item.value(); + } else if ( + typeof item.value == "string" || + typeof item.value == "number" || + typeof item.value == "boolean" + ) { + fmData[item.keyName] = item.value; + } else if (typeof item.value == "undefined") { + fmData[item.keyName] = ""; + } else { + fmData[item.keyName] = item.value || ""; + console.error( + "不应该直接传入数组或对象的值,这样会导致传入的值被子组件修改。editParams-------------cpts/base/cpts/edit.vue", + item + ); + } + if (item.supValues) { item.supValues.forEach((value, index) => { - fmData[item.supKeys[index]] = value; + if (typeof value == "function") { + fmData[item.supKeys[index]] = value(); + } else if ( + typeof value == "string" || + typeof value == "number" || + typeof value == "boolean" + ) { + fmData[item.supKeys[index]] = value; + } else if (typeof value == "undefined") { + fmData[item.supKeys[index]] = ""; + } else { + fmData[item.supKeys[index]] = value; + console.error( + "不应该直接传入数组或对象的值,这样会导致传入的值被子组件修改。editParams-------------cpts/base/cpts/edit.vue", + item + ); + } }); } - if (item.type == "select") { + if (item.type == "select" || item.type == "cascader") { if (item.optionUrl) { this.getFmOptions( index, item.optionUrl, - item.optionUrlParams || {} + item.optionUrlParams || {}, + item.optionCook || null ); } } else if (item.type == "address") { @@ -440,18 +503,119 @@ export default { this.iniLoaded = true; }, - async getFmOptions(index, url, params) { + handleClickHtmlNode(e) { + //在判断事件目标节点的时候,考虑到兼容性应该统一转换成大写或小写进行判断 + if (e.target.localName.toLowerCase() === "a") { + // 通过判端目标节点以后,就能在这里对其进行操作啦。 + let url = e.target.getAttribute("src"); //获取a标签属性,我这里自定义了一个属性data-id并将id赋值给了该属性,如何需要获取click方法的参数,需要获取a标签的click属性,并手动解析获取里面的参数 + window.open(url); + } + }, + + async getFmOptions(index, url, params, cookFn) { const { data, code, msg } = await requestPost(url, { ...params, }); if (code === 0) { - this.editParams[index].optionList = data || []; + this.editParams[index].optionList = + typeof cookFn == "function" ? cookFn(data) : data || []; } else { this.$message.error("请求检索基础数据失败!"); } }, + handleChangeCascader(vals, item) { + this.fmData[item["keyName"]] = vals; + if (typeof item.handleChangeFn == "function") { + item.handleChangeFn(vals, item, this); + } + }, + handleChangeSelect(vals, item) { + console.log(vals, item); + this.fmData[item["keyName"]] = vals; + if (typeof item.handleChangeFn == "function") { + item.handleChangeFn(vals, item, this); + } + }, + + beforeImgUpload(file, item) { + if (typeof item.beforeImgUpload == "function") { + if (!item.beforeImgUpload(file, item, this)) return false; + } + return true; + }, + + handleImgRemove(file, item) { + console.log("handleImgRemove", file); + let url = file.response ? file.response.data.url : file.url; + if (url) { + let { fmData } = this; + this.fmData[item.keyName] = fmData[item.keyName].filter( + (item) => item.url !== url + ); + if (item.supKeys && Array.isArray(item.supKeys)) { + if (item.supKeys.length > 0) { + this.fmData[item.supKeys[0]] = fmData[item.keyName].map( + (item) => item.url + ); + } + if (item.supKeys.length > 1) { + this.fmData[item.supKeys[1]] = + this.fmData[item.supKeys[0]][0] || ""; + } + } + } + }, + + handleImgExceed(res, item) { + console.log(res); + // this.$message({ + // type: "warning", + // message: "文件数量最多不超过三个", + // }); + }, + + handleImgSuccess(res, file, item) { + console.log("handleImgSuccess", res); + if (res.code === 0 && res.msg === "success") { + let { fmData } = this; + // let picItem = { + // url: res.data.url, + // name: file.name, + // size: file.size, + // type: file.type, + // format: file.name.split(".").pop(), + // }; + let picItem = file; + picItem.url = res.data.url; + picItem.format = file.name.split(".").pop(); + + if (Array.isArray(this.fmData[item.keyName])) { + this.fmData[item.keyName].push(picItem); + } else { + this.fmData[item.keyName] = [picItem]; + } + if (item.supKeys && Array.isArray(item.supKeys)) { + if (item.supKeys.length > 0) { + this.fmData[item.supKeys[0]] = fmData[item.keyName].map( + (item) => item.url + ); + } + if (item.supKeys.length > 1) { + this.fmData[item.supKeys[1]] = + this.fmData[item.supKeys[0]][0] || ""; + } + } + } else { + this.$message.error(res.msg); + } + }, + + handleImgError(res, file, item) { + console.log(res); + }, + // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap(item) { let { latitude, longitude } = this.$store.state.user; @@ -564,8 +728,13 @@ export default { [idName]: formId, }; - const { data, code, msg } = await requestPost(url, params); + let { data, code, msg } = await requestPost(url, params); if (code === 0) { + const { editConfig } = this; + console.log("xxxxxxxxxxxxxxxxxxxxxx", editConfig); + if (editConfig && typeof editConfig.cookInfoFn == "function") { + data = editConfig.cookInfoFn(data); + } this.fmData = { ...this.fmData, ...data, @@ -590,6 +759,28 @@ export default { window.open(src); }, + // 过滤文本 + dormatHtml(content) { + if ( + content.startsWith( + "\n\n\n\n\n" + ) && + content.endsWith("\n\n") + ) { + content = content.slice(45, -16); + } + return content; + }, + + cookBeforeSubmit(data) { + Object.keys(data).forEach((k) => { + if (typeof data[k] == "string") { + data[k] = this.dormatHtml(data[k]); + } + }); + return data; + }, + async handleComfirm() { this.btnDisable = true; setTimeout(() => { @@ -623,13 +814,23 @@ export default { }, async submit() { + const { editConfig, fmData, formType, editFixedParams } = this; + if ( + typeof editConfig.beforeSubmit == "function" && + !editConfig.beforeSubmit(formType, fmData, this) + ) { + return; + } + let url = ""; let params = { - ...this.fmData, - ...this.editFixedParams, + ...fmData, + ...editFixedParams, // serviceType: this.fmData.serviceTypeArr.join(","), }; + params = this.cookBeforeSubmit(params); + if (this.formType === "add") { url = this.addUrl; } else { @@ -643,6 +844,7 @@ export default { type: "success", message: "操作成功", }); + this.handleCancle(); this.$emit("afterEdit"); this.btnDisable = false; } else { @@ -663,23 +865,50 @@ export default { margin-top: 30px; &.z-div { - display: flex; + .list { + display: flex; + flex-wrap: wrap; + + .item { + min-width: 45%; + + .item-rich-text { + width: 817px; + max-height: 500px; + overflow: auto; + + img { + max-width: 100%; + } + &.z-show { + box-sizing: border-box; + padding: 15px; + border: 1px solid #eee; + height: auto; + } + } + } + } + + .item-show { + width: 324px; + } .item-input { - width: 225px; + width: 324px; } .item-select { - width: 225px; + width: 324px; } .item-number { - width: 125px; + width: 180px; } .address-item { - width: 450px; + width: 350px; .address-item-input { - width: 85%; + width: 74%; } .address-item-input2 { margin-left: 5px; @@ -687,12 +916,44 @@ export default { } } } + .avatar-uploader { + &.z-full { + /deep/ .el-upload.el-upload--picture-card { + display: none !important; + } + } + + a { + display: flex; + align-items: center; + justify-content: center; + color: #65a5f9; + i { + margin-right: 4px; + color: #65a5f9; + font-size: 18px; + } + &:hover { + text-decoration: none; + } + } + } + .item-rich-text { + width: 600px; + height: 500px; + img { + max-width: 100%; + } + .item-show { + width: 100%; + } + } + + .item-select, + .item-show, .item-input { width: 450px; } - .item-select { - width: 225px; - } .item-number { width: 225px; } diff --git a/src/views/modules/cpts/base/index.vue b/src/views/modules/cpts/base/index.vue index 3c8250b48..d6660da39 100644 --- a/src/views/modules/cpts/base/index.vue +++ b/src/views/modules/cpts/base/index.vue @@ -13,7 +13,7 @@ + +
-
+
+ + + + @@ -202,7 +256,8 @@ @closed="handleClose" > -