From f74b0b78e70f72808535b3d4c117849a64f6e7f7 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 27 Dec 2023 10:41:13 +0800
Subject: [PATCH] 场所维护和编辑合并

---
 src/views/place/components/baseAllInfo.vue |  498 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 498 insertions(+), 0 deletions(-)

diff --git a/src/views/place/components/baseAllInfo.vue b/src/views/place/components/baseAllInfo.vue
new file mode 100644
index 0000000..24baba6
--- /dev/null
+++ b/src/views/place/components/baseAllInfo.vue
@@ -0,0 +1,498 @@
+<template>
+    <div class="cur-container-box">
+        <div class="content-box">
+            <box-title class="m10" :classVal="9" :title="'基本信息'"></box-title>
+            <avue-form :option="option" v-model="form"></avue-form>
+
+            <box-title class="m10" :classVal="9" :title="'其他信息'"></box-title>
+            <avue-form :option="optionDetail" v-model="placeForm"></avue-form>
+
+            <box-title class="m10" :classVal="9" :title="'从业人员'"></box-title>
+            <avue-crud :option="placeOption" :table-loading="loading" :data="placeExt" ref="crud" v-model="houseHoldForm"
+                :permission="permissionList" @row-del="houseHoldRowDel" @row-update="houseHoldRowUpdate"
+                @row-save="houseHoldRowSave" :page.sync="holdPage" @current-change="holdCurrentChange"
+                @size-change="holdSizeChange" @refresh-change="refreshHoldChange" @on-load="holdOnLoad">
+            </avue-crud>
+        </div>
+
+        <div class="footer-btn-box">
+            <el-button size="small" type="primary" @click="dataUpdate">保 存</el-button>
+
+            <el-button size="small" @click="closeRowDetails">关 闭</el-button>
+        </div>
+    </div>
+</template>
+
+<script>
+import {
+    getPlace,
+    getPlaceExt,
+
+    holdRemove,
+    holdAdd,
+    holdUpdate,
+    getHoldList,
+
+    update,
+    updatePlaceExt,
+} from "@/api/place/place"
+
+import website from '@/config/website'
+
+import boxTitle from './boxTitle'
+
+export default {
+    data () {
+        return {
+            placeExt: [],
+
+            form: {},
+            option: {
+                submitBtn: false,
+                emptyBtn: false,
+
+                column: [
+                    {
+                        label: "场所名称",
+                        prop: "placeName",
+                    },
+
+                    {
+                        label: "负责人",
+                        prop: "principal",
+                    },
+
+                    {
+                        hide: true,
+                        parent: false,
+                        label: "所属社区",
+                        prop: "neiCode",
+                        search: false,
+                        width: 150,
+                        type: "tree",
+                        dicUrl: "/api/blade-system/region/tree",
+                        props: {
+                            label: "name",
+                            value: "id",
+                        },
+                        cascader: ["gridId"],
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择所属社区",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        hide: true,
+                        label: "所属网格",
+                        prop: "gridId",
+                        type: "tree",
+                        cell: true,
+                        props: {
+                            label: "gridName",
+                            value: "id",
+                        },
+                        dicUrl:
+                            "/api/blade-grid/grid/getGridList?communityCode={{neiCode}}",
+                        rules: [
+                            {
+                                required: true,
+                                message: "请选择所属网格",
+                                trigger: "blur",
+                            },
+                        ],
+                    },
+                    {
+                        label: "场所标签",
+                        prop: "label",
+                        type: "cascader",
+                        dicUrl: "/api/blade-category/category/getCategory?level=2",
+                        cascader: ["smallLabel"],
+                        props: {
+                            label: "categoryName",
+                            value: "categoryNo"
+                        },
+                        dataType: "string",
+                        hide: true,
+                        rules: [{
+                            required: true,
+                            message: "请输入场所标签",
+                            trigger: "blur",
+                        },],
+                    },
+                    {
+                        label: "",
+                        prop: "smallLabel",
+                        type: "cascader",
+                        dicUrl: "/api/blade-category/category/getCategory?parentNo={{label}}",
+                        props: {
+                            label: "categoryName",
+                            value: "categoryNo"
+                        },
+                        dataType: "string",
+                        hide: true,
+                    },
+                    {
+                        width: 110,
+                        label: "电话",
+                        prop: "principalPhone",
+                        search: true,
+                        searchSpan: 4,
+                        slot: true,
+                    },
+                    {
+                        label: "场所照片",
+                        prop: "imageUrls",
+                        width: 80,
+                        type: "upload",
+                        listType: "picture-card",
+                        dataType: "string",
+                        multiple: true,
+                        action: "/api/blade-resource/oss/endpoint/put-file",
+                        propsHttp: {
+                            res: "data",
+                            name: 'name',
+                            url: "link",
+                        },
+                        span: 24,
+                    },
+                    {
+                        label: "位置",
+                        prop: "localtion",
+                        span: 24,
+                        minWidth: 220,
+                        overHidden: true,
+                        // rules: [{
+                        //     required: true,
+                        //     message: "请输入区域",
+                        //     trigger: "blur",
+                        // },],
+                    }
+                ]
+            },
+
+            placeForm: {},
+            optionDetail: {
+                submitBtn: false,
+                emptyBtn: false,
+                column: [
+                    {
+                        label: '场所名称',
+                        prop: 'placeName',
+                    },
+                    {
+                        label: '法人信息',
+                        prop: 'legalPerson'
+                    },
+                    {
+                        label: '法人电话',
+                        prop: 'legalTel'
+                    },
+                    {
+                        label: '场所位置',
+                        prop: 'localtion'
+                    },
+
+                    {
+                        label: "营业执照",
+                        prop: "imageUrls",
+                        width: 80,
+                        type: "upload",
+                        listType: "picture-card",
+                        dataType: "string",
+                        multiple: true,
+                        action: "/api/blade-resource/oss/endpoint/put-file",
+                        propsHttp: {
+                            res: "data",
+                            name: 'name',
+                            url: "link",
+                        },
+                        span: 24,
+                    },
+
+                    {
+                        label: "场所平面图",
+                        prop: "planImageUrls",
+                        width: 80,
+                        type: "upload",
+                        listType: "picture-card",
+                        dataType: "string",
+                        multiple: true,
+                        action: "/api/blade-resource/oss/endpoint/put-file",
+                        propsHttp: {
+                            res: "data",
+                            name: 'name',
+                            url: "link",
+                        },
+                        span: 24,
+                    },
+
+                ]
+            },
+
+            loading: true,
+            placeOption: {
+                menu: true,
+                height: 300,
+                calcHeight: 54,
+                dialogWidth: 950,
+                tip: false,
+                searchShow: false,
+                addBtn: true,
+                delBtn: true,
+                editBtn: true,
+                border: true,
+                index: true,
+                dialogClickModal: false,
+                column: [{
+                    label: "名称",
+                    prop: "name",
+                    searchSpan: 4,
+                    search: true,
+                }, {
+                    label: "电话",
+                    prop: "telephone",
+                    searchSpan: 4,
+                    search: true,
+                }, {
+                    label: "暂住地",
+                    prop: "tempAddress",
+                    searchSpan: 4,
+                    search: true,
+                },]
+            },
+            holdPage: {
+                pageSize: 20,
+                currentPage: 1,
+                total: 0,
+            },
+            houseHoldForm: {},
+        }
+    },
+
+    components: { boxTitle },
+
+    inject: ["placeElement"],
+
+    watch: {
+        'placeElement.curRow': {
+            handler (newData) {
+                const that = this
+                if (newData && 'id' in newData && newData['id'] != null && newData['id'] != '') {
+
+                    that.$axios.all([
+                        getPlace(newData['id']),
+                        getPlaceExt({ placeId: newData['id'] }),
+                    ]).then(that.$axios.spread(function (baseInfo, restInfo) {
+                        that.form = baseInfo.data.data
+
+                        if (that.form.imageUrls && that.form.imageUrls.length) {
+                            that.form.imageUrls = that.form.imageUrls.split(",").filter(item => item != '').map(item => website.minioUrl + item).join(',')
+                        }
+
+                        if (that.form.placePoiLabelVOList && that.form.placePoiLabelVOList.length) {
+                            let lebelTwo = that.form.placePoiLabelVOList.find(item => {
+                                return item.type == 2
+                            })
+
+                            if (lebelTwo) that.form.label = String(lebelTwo.poiCode)
+
+                            let lebelThree = that.form.placePoiLabelVOList.find(item => {
+                                return item.type == 3
+                            })
+
+                            if (lebelThree) that.form.smallLabel = String(lebelThree.poiCode)
+                        }
+
+                        const data = restInfo.data.data
+
+                        if (data) {
+                            let imageUrls = data.imageUrls
+                            let planImageUrls = data.planImageUrls
+
+                            if (imageUrls && imageUrls.length) {
+                                imageUrls = imageUrls.split(',').filter(item => item != '').map(item => website.minioUrl + item).join(",")
+                            }
+
+                            if (planImageUrls && planImageUrls.length) {
+                                planImageUrls = planImageUrls.split(',').filter(item => item != '').map(item => website.minioUrl + item).join(",")
+                            }
+
+                            that.placeForm = {
+                                ...data,
+                                imageUrls,
+                                planImageUrls
+                            }
+                        }
+
+                    }))
+
+                    that.holdOnLoad(this.holdPage)
+                }
+            },
+            immediate: true
+        }
+    },
+
+    methods: {
+        selectionClear () {
+            this.$nextTick(() => {
+                this.$refs.crud && this.$refs.crud.toggleSelection()
+            })
+        },
+
+        houseHoldRowUpdate (row, index, done, loading) {
+            holdUpdate(row).then(
+                () => {
+                    this.holdOnLoad(this.holdPage)
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                    done()
+                },
+                (error) => {
+                    window.console.log(error)
+                    loading()
+                }
+            )
+        },
+
+        houseHoldRowDel (row) {
+            this.$confirm("确定将选择数据删除?", {
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                type: "warning",
+            })
+                .then(() => {
+                    return holdRemove(row.id)
+                })
+                .then(() => {
+                    this.holdOnLoad(this.holdPage)
+
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                })
+        },
+
+        houseHoldRowSave (row, done, loading) {
+            holdAdd({
+                ...row,
+                placeId: this.placeElement.curRow.id
+            }).then(
+                () => {
+                    this.holdOnLoad(this.holdPage)
+
+                    this.$message({
+                        type: "success",
+                        message: "操作成功!",
+                    })
+                    done()
+                },
+                (error) => {
+                    window.console.log(error)
+                    loading()
+                }
+            )
+        },
+
+        refreshHoldChange () {
+            this.holdOnLoad(this.holdPage)
+        },
+
+        holdOnLoad (holdPage, params = {}) {
+            if (!this.placeElement.curRow.id) return
+
+            let values = {
+                ...params,
+                placeId: this.placeElement.curRow.id
+            }
+
+            getHoldList(holdPage.currentPage, holdPage.pageSize, values).then((res) => {
+                const data = res.data.data
+
+                this.holdPage.total = data.total
+                this.placeExt = data.records
+
+                this.loading = false
+                this.selectionClear()
+            })
+        },
+
+        holdCurrentChange (currentPage) {
+            this.holdPage.currentPage = currentPage
+        },
+
+        holdSizeChange (pageSize) {
+            this.holdPage.pageSize = pageSize
+        },
+
+        dataUpdate () {
+            const that = this
+
+            let imageUrls = this.form.imageUrls
+
+            if (imageUrls.length > 0) {
+                var urls = []
+                var split = imageUrls.split(",").filter(item => item != '')
+                split.forEach(url => {
+                    var names = url.split("jczz/")
+                    urls.push(names[1])
+                })
+                imageUrls = urls.join(",")
+            }
+
+            that.$axios.all([
+                update({
+                    // ...this.placeElement.curRow,
+                    ...this.form,
+                    imageUrls
+                }),
+                updatePlaceExt(this.placeForm)
+            ]).then(that.$axios.spread(function () {
+                that.$message({
+                    type: "success",
+                    message: "操作成功!",
+                })
+
+                that.placeElement.onLoad(that.placeElement.page, that.placeElement.query)
+
+                that.closeRowDetails()
+            }))
+        },
+
+        closeRowDetails () {
+            this.placeElement.roleBox = false
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.cur-container-box {
+    display: flex;
+    flex-direction: column;
+    width: 100%;
+    height: 100%;
+    overflow: hidden;
+
+    .content-box {
+        margin: 0 4px;
+        padding: 0 10px;
+        height: 0;
+        flex: 1;
+        overflow: hidden;
+        overflow-y: auto;
+    }
+
+    .footer-btn-box {
+        margin-top: 10px;
+        display: flex;
+        justify-content: center;
+    }
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.3