shuishen
2024-01-24 d16d10d94fddff86bdfd87113e7fd2cebe8b7cd7
src/views/cGovernance/gridWorkLog.vue
@@ -6,6 +6,10 @@
            :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad">
            <template slot="householdIdType" slot-scope="{item,value,label}">
                <span>{{ showNamePhone(item) }}</span>
            </template>
            <template slot="menuLeft">
                <el-button size="small" icon="el-icon-delete" plain v-if="permission.gridWorkLog_delete"
                    @click="handleDelete">删 除
@@ -16,13 +20,15 @@
</template>
<script>
import { getPersonPublicSelect } from "@/api/public"
import { getDetatils as householdDetail } from "@/api/userHouse/list/houseHold"
import { getList, remove, update, add, getGridWorkLog } from "@/api/grid/gridWorkLog"
import { getList as getHouseholdList, getDetatils as getHouseholdDetail } from "@/api/userHouse/list/houseHold"
import { mapGetters } from "vuex"
import website from '@/config/website'
export default {
    data () {
    data() {
        return {
            form: {},
            query: {},
@@ -35,13 +41,16 @@
            datetime: "",
            selectionList: [],
            option: {
                labelWidth: 120,
                searchLabelWidth: 96,
                searchShow: true,
                searchMenuSpan: 3,
                menuWidth: 210,
                height: "auto",
                calcHeight: 54,
                dialogWidth: 950,
                tip: false,
                searchShow: true,
                searchMenuSpan: 3,
                menuWidth: 280,
                border: false,
                //stripe:true,
                index: true,
@@ -51,11 +60,10 @@
                dialogClickModal: false,
                column: [
                    {
                        width: 120,
                        label: "走访类型",
                        prop: "type",
                        span: 12,
                        labelWidth: 120,
                        searchLabelWidth: 120,
                        searchSpan: 4,
                        search: true,
                        type: "select",
@@ -73,8 +81,10 @@
                            },
                        ],
                    },
                    {
                        label: "重点人员类型",
                        overHidden: true,
                        label: "重点人群",
                        prop: "personType",
                        span: 12,
                        type: "tree",
@@ -83,155 +93,102 @@
                            label: "name",
                            value: "id"
                        },
                        labelWidth: 120,
                        searchLabelWidth: 120,
                        searchSpan: 5,
                        searchSpan: 4,
                        search: true,
                        change: ({ value, column, item, dic }) => {
                            this.getUserList(value)
                        },
                        rules: [
                            {
                                required: true,
                                message: "请选择重点人员类型",
                                message: "请选择重点人群",
                                trigger: "blur",
                            },
                        ],
                    },
                    // {
                    //     label: "人员姓名",
                    //     prop: "name",
                    //     span: 12,
                    //     labelWidth: 120,
                    //     searchSpan: 4,
                    //     search: true,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请输入人员姓名",
                    //             trigger: "blur",
                    //         },
                    //     ],
                    // },
                    {
                        label: "人员姓名",
                        prop: "householdId",
                        hide: true,
                        type: "table",
                        span: 12,
                        labelWidth: 120,
                        searchSpan: 4,
                        width: 110,
                        display: false,
                        label: "被访人姓名",
                        prop: "name",
                        searchLabelWidth: 120,
                        searchSpan: 5,
                        search: true,
                        children: {
                            border: true,
                            height: 400,
                            searchShow: true,
                            searchMenuSpan: 6,
                            submitText: "确定",
                            column: [
                                {
                                    label: "姓名",
                                    prop: "name",
                                    search: true,
                                    searchSpan: 4,
                                    rules: [
                                        {
                                            required: true,
                                            message: "请输入姓名",
                                            trigger: "blur",
                                        },
                                    ],
                                },
                                {
                                    label: "联系方式",
                                    prop: "phoneNumber",
                                    search: true,
                                    searchSpan: 4,
                                    rules: [
                                        {
                                            required: true,
                                            message: "请输入联系方式",
                                            trigger: "blur",
                                        },
                                    ],
                                },
                                {
                                    label: "地址",
                                    search: true,
                                    searchSpan: 8,
                                    prop: "currentAddress",
                                    display: false
                                },
                            ],
                        },
                        page: {
                            pageSize: 10,
                            currentPage: 1,
                            total: 0
                        },
                        formatter: (row) => {
                            this.form.phoneNumber = row.phoneNumber
                            return row.name
                        },
                        onLoad: ({
                            page,
                            value,
                            data
                        }, callback) => {
                            //首次加载去查询对应的值
                            if (value) {
                                getHouseholdDetail(value).then(res => {
                                    var resData = res.data.data
                                    // 查询对应行数据
                                    callback(resData)
                                    return
                                })
                            }
                            if (page) {
                                this.loading = true
                                var params = {
                                    ...data,
                                    townStreetCode: "361102005"
                                }
                                getHouseholdList(page.currentPage, page.pageSize, Object.assign(params)).then(res => {
                                    const resData = res.data.data
                                    var total = resData.total
                                    var data = resData.records
                                    this.loading = false
                                    this.selectionClear()
                                    //分页查询信息
                                    callback({
                                        total: total,
                                        data: data
                                    })
                                })
                            }
                        },
                    },
                    {
                        disabled: true,
                        label: "被访人姓名",
                        prop: "householdId",
                        type: 'select',
                        remote: true,
                        hide: true,
                        dicUrl: "",
                        props: {
                            label: 'name',
                            value: 'id'
                        }
                            value: 'id',
                        },
                        dicData: [],
                        rules: [
                            {
                                required: true,
                                message: '请输入姓名',
                                trigger: 'blur'
                            }
                        ],
                    },
                    {
                        width: 120,
                        label: "联系方式",
                        prop: "phone",
                        span: 12,
                        disabled: true,
                        labelWidth: 120,
                        searchSpan: 4,
                        search: true,
                    },
                    {
                        width: 156,
                        overHidden: true,
                        label: "走访地址",
                        prop: "address",
                        span: 24,
                        labelWidth: 120,
                        disabled: true,
                    },
                    {
                        width: 110,
                        label: "所属街道",
                        display: false,
                        prop: "townName",
                    },
                    {
                        width: 156,
                        overHidden: true,
                        label: "所属社区",
                        display: false,
                        prop: "neiName",
                        search: true,
                        searchSpan: 4
                    },
                    {
                        width: 110,
                        overHidden: true,
                        label: "所属网格",
                        display: false,
                        prop: "gridName",
                    },
                    {
                        width: 144,
                        label: "走访时间",
                        prop: "workTime",
                        width: 160,
                        labelWidth: 120,
                        searchLabelWidth: 120,
                        type: "date",
                        row: true,
                        format: "yyyy-MM-dd HH:mm:ss",
                        valueFormat: "yyyy-MM-dd HH:mm:ss",
                        rules: [
@@ -242,20 +199,30 @@
                            },
                        ],
                    },
                    {
                        label: "内容",
                        labelWidth: 120,
                        overHidden: true,
                        label: "走访内容",
                        prop: "context",
                        type: "textarea",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请输入走访内容",
                                trigger: "blur",
                            },
                        ],
                    },
                    {
                        width: 110,
                        label: "走访取证",
                        prop: "url",
                        type: "upload",
                        labelWidth: 120,
                        listType: "picture-img",
                        listType: "picture-card",
                        dataType: "string",
                        multiple: true,
                        action: "/api/blade-resource/oss/endpoint/put-file",
                        propsHttp: {
                            res: "data",
@@ -263,32 +230,97 @@
                            url: "link",
                        },
                        span: 24,
                    }
                    },
                    {
                        width: 110,
                        label: "录入人",
                        display: false,
                        prop: "createUserName",
                    },
                    {
                        display: false,
                        width: 144,
                        label: "上报时间",
                        prop: "createTime",
                        searchLabelWidth: 120,
                        type: "date",
                        format: "yyyy-MM-dd HH:mm:ss",
                        valueFormat: "yyyy-MM-dd HH:mm:ss",
                        rules: [
                            {
                                required: true,
                                message: "请输入上报时间",
                                trigger: "blur",
                            },
                        ],
                    },
                ],
            },
            data: [],
        }
    },
    watch: {
        "form.householdId": {
            // form是表单或者表格绑定的数据集,v-model='form'
            handler (val) {
                this.$nextTick(() => {
                    console.log(this.$refs, 66666)
                    getHouseholdDetail(val).then(res => {
                        const data = res.data.data
                        this.form.phoneNumber = data.phoneNumber
                        this.form.currentAddress = data.currentAddress
                    })
                })
            handler(val) {
                if (val) {
                    householdDetail(val).then(res => {
                        let data = res.data.data
                        this.form.phone = data.phoneNumber
                        this.form.address = data.currentAddress
                    })
                }
            }
        },
        'form.personType': {
            handler(newData) {
                let householdIdColumn = this.findObject(
                    this.option.column,
                    'householdId'
                )
                if (newData) {
                    householdIdColumn.disabled = false
                } else {
                    householdIdColumn.disabled = true
                }
            },
            immediate: true,
        },
        'form.type': {
            handler(newData) {
                let householdIdColumn = this.findObject(
                    this.option.column,
                    'householdId'
                )
                let personTypeColumn = this.findObject(
                    this.option.column,
                    'personType'
                )
                if (newData == 1) {
                    householdIdColumn.disabled = false
                    personTypeColumn.display = false
                } else {
                    householdIdColumn.disabled = true
                    personTypeColumn.display = true
                }
            },
        },
    },
    computed: {
        ...mapGetters(["permission", "userInfo"]),
        permissionList () {
        permissionList() {
            return {
                addBtn: this.vaildData(this.permission.gridWorkLog_add, true),
                viewBtn: this.vaildData(this.permission.gridWorkLog_view, true),
@@ -296,16 +328,37 @@
                editBtn: this.vaildData(this.permission.gridWorkLog_edit, true),
            }
        },
        ids () {
        ids() {
            let ids = []
            this.selectionList.forEach((ele) => {
                ids.push(ele.id)
            })
            return ids.join(",")
        },
        showNamePhone() {
            return (data) => {
                if (data.phoneNumber && data.phoneNumber.trim() != '') {
                    return `${data.name}(${data.phoneNumber})`
                }
                return data.name
            }
        }
    },
    created() {
        this.getUserList()
    },
    methods: {
        rowSave (row, done, loading) {
        getUserList(param = '') {
            let dicUrl = `/api/blade-household/household/selectHouseholdList?labelId=${param}&searchKey={{key}}&limit=20`
            const column = this.findObject(this.option.column, "householdId")
            column.dicUrl = dicUrl
        },
        rowSave(row, done, loading) {
            if (row.url.length > 0) {
                var urls = []
                var split = row.url.split(",")
@@ -330,7 +383,7 @@
                }
            )
        },
        rowUpdate (row, index, done, loading) {
        rowUpdate(row, index, done, loading) {
            if (row.url.length > 0) {
                var urls = []
                var split = row.url.split(",")
@@ -355,7 +408,7 @@
                }
            )
        },
        rowDel (row) {
        rowDel(row) {
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
@@ -372,24 +425,24 @@
                    })
                })
        },
        searchReset () {
        searchReset() {
            this.query = {}
            this.onLoad(this.page)
        },
        searchChange (params, done) {
        searchChange(params, done) {
            this.query = params
            this.page.currentPage = 1
            this.onLoad(this.page, params)
            done()
        },
        selectionChange (list) {
        selectionChange(list) {
            this.selectionList = list
        },
        selectionClear () {
        selectionClear() {
            this.selectionList = []
            this.$refs.crud.toggleSelection()
        },
        handleDelete () {
        handleDelete() {
            if (this.selectionList.length === 0) {
                this.$message.warning("请选择至少一条数据")
                return
@@ -411,33 +464,41 @@
                    this.$refs.crud.toggleSelection()
                })
        },
        beforeOpen (done, type) {
        beforeOpen(done, type) {
            if (["edit", "view"].includes(type)) {
                getGridWorkLog(this.form.id).then((res) => {
                    this.form = res.data.data
                    if (this.form.url.length > 0) {
                        var urls = []
                        var names = this.form.url.split(",")
                        names.forEach(name => {
                            urls.push(website.minioUrl + name)
                        })
                        this.form.url = urls.join(",")
                    if (this.form.url) {
                        if (this.form.url.length > 0) {
                            var urls = []
                            var names = this.form.url.split(",")
                            names.forEach(name => {
                                urls.push(website.minioUrl + name)
                            })
                            this.form.url = urls.join(",")
                        }
                    }
                    getPersonPublicSelect({
                        id: this.form.householdId
                    }).then(res => {
                        const column = this.findObject(this.option.column, "householdId")
                        column.dicData = res.data.data
                    })
                })
            }
            // con
            done()
        },
        currentChange (currentPage) {
        currentChange(currentPage) {
            this.page.currentPage = currentPage
        },
        sizeChange (pageSize) {
        sizeChange(pageSize) {
            this.page.pageSize = pageSize
        },
        refreshChange () {
        refreshChange() {
            this.onLoad(this.page, this.query)
        },
        onLoad (page, params = {}) {
        onLoad(page, params = {}) {
            const { dateTime } = this.query
            let values = {
                ...params,
@@ -457,13 +518,15 @@
                this.page.total = data.total
                this.data = data.records
                this.data.forEach(item => {
                    if (item.url.length > 0) {
                        var urls = []
                        var names = item.url.split(",")
                        names.forEach(name => {
                            urls.push(website.minioUrl + name)
                        })
                        item.url = urls.join(",")
                    if (item.url) {
                        if (item.url.length > 0) {
                            var urls = []
                            var names = item.url.split(",")
                            names.forEach(name => {
                                urls.push(website.minioUrl + name)
                            })
                            item.url = urls.join(",")
                        }
                    }
                })
                this.loading = false