linwe
2024-06-12 91fbddb0c07bcab4f88f247a3367e9efb0154c2d
src/views/place/practitioner.vue
@@ -1,9 +1,9 @@
<template>
  <basic-container>
    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
      :permission="permissionList" @row-save="rowSave" @row-del="rowDel" :before-open="beforeOpen" @search-change="searchChange"
      @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
      @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
      :permission="permissionList" @row-save="rowSave" @row-del="rowDel" :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-scope="{row, size}" slot="age">
        <el-tag :size="size">{{
      row.age
@@ -23,15 +23,15 @@
      </template>
      <template slot-scope="{row, size}" slot="telephone">
                <el-button :size="size" type="text" @click="showStringDispose(row, 'telephoneflag')"
                    v-text="textDispose(row, 'telephoneflag', 'telephone')">
                </el-button>
            </template>
            <template slot-scope="{row, size}" slot="idCard">
                <el-button :size="size" type="text" @click="showStringDispose(row, 'idCardflag')"
                    v-text="textDispose(row, 'idCardflag', 'idCard')">
                </el-button>
            </template>
        <el-button :size="size" type="text" @click="showStringDispose(row, 'telephoneflag')"
          v-text="textDispose(row, 'telephoneflag', 'telephone')">
        </el-button>
      </template>
      <template slot-scope="{row, size}" slot="idCard">
        <el-button :size="size" type="text" @click="showStringDispose(row, 'idCardflag')"
          v-text="textDispose(row, 'idCardflag', 'idCard')">
        </el-button>
      </template>
      <template slot="menuLeft">
        <!-- <el-button size="small" icon="el-icon-delete" plain v-if="permission.place_delete" @click="handleDelete">删 除
@@ -74,373 +74,397 @@
</template>
<script>
import {
  getPractitionerList as getList,
  add,
  getWarningPersonnelCount as getCount
} from "@/api/place/place"
import {
  remove
} from "@/api/place/practitioner"
import {
  mapGetters
} from "vuex"
  import {
    getPractitionerList as getList,
    add,
    getWarningPersonnelCount as getCount
  } from "@/api/place/place"
  import {
    remove
  } from "@/api/place/practitioner"
  import {
    mapGetters
  } from "vuex"
import website from '@/config/website'
  import website from '@/config/website'
import auditBase from './components/auditBase'
import baseAllInfo from './components/baseAllInfo'
  import auditBase from './components/auditBase'
  import baseAllInfo from './components/baseAllInfo'
export default {
  data() {
    //手机号格式校验
    let validatorPhone = function (rule, value, callback) {
      if (value) {
        if (!/^1[3456789]\d{9}$/.test(value)) {
          callback(new Error('手机号格式有误!'))
        } else {
          callback()
        }
      }
      callback()
    }
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      datetime: "",
      selectionList: [],
      option: {
        labelWidth: 120,
        searchLabelWidth: 96,
        searchShow: true,
        searchMenuSpan: 3,
        menuWidth: 160,
        height: "auto",
        calcHeight: 54,
        dialogWidth: 950,
        tip: false,
        border: true,
        addBtn: false,
        index: true,
        viewBtn: true,
        editBtn: false,
        delBtn: true,
        dialogClickModal: false,
        column: [{
          overHidden: true,
          label: "姓名",
          span: 12,
          prop: "name",
          searchSpan: 4,
          search: true,
          searchLabelWidth: 76,
        },
        {
          label: "性别",
          prop: "gender",
          width: 80,
          align:"center",
          type: "select",
          dicData: [
            {
              label: "男",
              value: 1
            },
            {
              label: "女",
              value: 0
            }
          ]
        },
        {
          label: "民族",
          width: 80,
          dicUrl: "/api/blade-system/dict-biz/tree?code=nationType",
          props: {
            label: "title",
            value: "key",
          },
          prop: "ethnicity",
          type: "select",
          dataType: "number"
        },
        {
          overHidden: true,
          label: "身份证号",
          prop: "idCard",
          // search: true,
          width: 160,
          searchSpan: 4,
          slot: true,
        },
        {
          label: "电话号码",
          prop: "telephone",
          searchSpan: 4,
          searchLabelWidth: 110,
          search: true,
        },
        {
          width: 80,
          label: "年龄",
          prop: "age",
          align:"center"
        },
        {
          minWidth: 160,
          label: "现居住地",
          prop: "tempAddress",
        },
        {
          label: "岗位",
          prop: "jobNature",
        }, {
          width: 110,
          label: '从业人员照片',
          prop: 'employerImg',
          fileType: 'img',
          type: "upload",
          listType: "picture-card",
          dataType: "string",
          disabled: true,
          row: true,
          span: 12,
        }, {
          label: "工作单位",
          prop: "employer",
          searchSpan: 4
        },
        {
          width: 160,
          label: "标签",
          addDisplay: false,
          editDisplay: false,
          viewDisplay: false,
          prop: "categoryName",
          searchSpan: 4
        },
        {
          label: "状态",
          prop: "resignationFlag",
          align: 'center',
          searchSpan: 4,
          search: true,
          type: "select",
          dicData: [
            {
              label: "在职",
              value: "1"
            },
            {
              label: "已离职",
              value: "2"
            }
          ]
        },
        {
          label: "入职时间",
          prop: "employmentTime",
          hide: true,
        },
        {
          label: "离职时间",
          prop: "resignationTime",
          hide: true,
        },
        {
          label: "预警人员",
          addDisplay: false,
          editDisplay: false,
          viewDisplay: false,
          prop: "type",
          searchSpan: 4,
          hide: true,
          type: "select",
          search: true,
          dicData: [{
            label: "未成年人",
            value: 1
          },
          {
            label: "少数民族",
            value: 2
          },
          {
            label: "以上都有",
            value: 3
  export default {
    data() {
      //手机号格式校验
      let validatorPhone = function(rule, value, callback) {
        if (value) {
          if (!/^1[3456789]\d{9}$/.test(value)) {
            callback(new Error('手机号格式有误!'))
          } else {
            callback()
          }
        }
        callback()
      }
      return {
        form: {},
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0,
        },
        datetime: "",
        selectionList: [],
        option: {
          labelWidth: 120,
          searchLabelWidth: 96,
          searchShow: true,
          searchMenuSpan: 3,
          menuWidth: 160,
          height: "auto",
          calcHeight: 54,
          dialogWidth: 950,
          tip: false,
          border: true,
          addBtn: false,
          index: true,
          viewBtn: true,
          editBtn: false,
          delBtn: true,
          dialogClickModal: false,
          column: [{
              width: 110,
              label: "所属街道",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              prop: "townStreetName",
              search: true,
              searchSpan: 4
            },
            {
              width: 156,
              overHidden: true,
              label: "所属社区",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              prop: "neiName",
              search: true,
              searchSpan: 4,
              rules: [{
                required: true,
                message: "请选择所属社区",
                trigger: "blur",
              }],
            }, {
              overHidden: true,
              label: "姓名",
              span: 12,
              prop: "name",
              searchSpan: 4,
              search: true,
              searchLabelWidth: 76,
            },
            {
              label: "性别",
              prop: "gender",
              width: 80,
              align: "center",
              type: "select",
              dicData: [{
                  label: "男",
                  value: 1
                },
                {
                  label: "女",
                  value: 0
                }
              ]
            },
            {
              label: "民族",
              width: 80,
              dicUrl: "/api/blade-system/dict-biz/tree?code=nationType",
              props: {
                label: "title",
                value: "key",
              },
              prop: "ethnicity",
              type: "select",
              dataType: "number"
            },
            {
              overHidden: true,
              label: "身份证号",
              prop: "idCard",
              // search: true,
              width: 160,
              searchSpan: 4,
              slot: true,
            },
            {
              label: "电话号码",
              prop: "telephone",
              searchSpan: 4,
              searchLabelWidth: 110,
              search: true,
            },
            {
              width: 80,
              label: "年龄",
              prop: "age",
              align: "center"
            },
            {
              minWidth: 160,
              label: "现居住地",
              prop: "tempAddress",
            },
            {
              label: "岗位",
              prop: "jobNature",
            }, {
              width: 110,
              label: '从业人员照片',
              prop: 'employerImg',
              fileType: 'img',
              type: "upload",
              listType: "picture-card",
              dataType: "string",
              disabled: true,
              row: true,
              span: 12,
            }, {
              label: "工作单位",
              prop: "employer",
              searchSpan: 4
            },
            {
              width: 160,
              label: "标签",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              prop: "categoryName",
              searchSpan: 4
            },
            {
              label: "状态",
              prop: "resignationFlag",
              align: 'center',
              searchSpan: 4,
              search: true,
              type: "select",
              dicData: [{
                  label: "在职",
                  value: "1"
                },
                {
                  label: "已离职",
                  value: "2"
                }
              ]
            },
            {
              label: "入职时间",
              prop: "employmentTime",
              hide: true,
            },
            {
              label: "离职时间",
              prop: "resignationTime",
              hide: true,
            },
            {
              label: "预警人员",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              prop: "type",
              searchSpan: 4,
              hide: true,
              type: "select",
              search: true,
              dicData: [{
                  label: "未成年人",
                  value: 1
                },
                {
                  label: "少数民族",
                  value: 2
                },
                {
                  label: "以上都有",
                  value: 3
                }
              ],
            },
          ],
        },
        ],
        data: [],
        auditBasePopup: false,
        countInfo: {}
      }
    },
    provide() {
      return {
        placeElement: this,
      }
    },
    components: {
      auditBase,
      baseAllInfo
    },
    computed: {
      ...mapGetters(["permission", "userInfo"]),
      permissionList() {
        return {
          // addBtn: this.vaildData(this.permission.place_add, true),
          viewBtn: this.vaildData(this.permission.place_practitioner_view, true),
          delBtn: this.vaildData(this.permission.place_practitioner_delete, true),
          // editBtn: this.vaildData(this.permission.place_edit, true),
        }
      },
      data: [],
      ids() {
        let ids = []
        this.selectionList.forEach((ele) => {
          ids.push(ele.id)
        })
        return ids.join(",")
      },
      auditBasePopup: false,
      showConfirmFlag() {
        return (data) => {
          let tags = {
            text: '',
            type: ''
          }
          if (data == 1) {
            tags = {
              text: '待审核',
              type: 'warning'
            }
          } else if (data == 2) {
            tags = {
              text: '已审核',
              type: 'success'
            }
          } else if (data == 3) {
            tags = {
              text: '未通过',
              type: 'danger'
            }
          } else if (data == 4) {
            tags = {
              text: '待完善',
              type: 'info'
            }
          }
      countInfo: {}
    }
  },
  provide() {
    return {
      placeElement: this,
    }
  },
  components: {
    auditBase,
    baseAllInfo
  },
  computed: {
    ...mapGetters(["permission", "userInfo"]),
    permissionList() {
      return {
        // addBtn: this.vaildData(this.permission.place_add, true),
        viewBtn: this.vaildData(this.permission.place_practitioner_view, true),
        delBtn: this.vaildData(this.permission.place_practitioner_delete, true),
        // editBtn: this.vaildData(this.permission.place_edit, true),
      }
    },
    ids() {
      let ids = []
      this.selectionList.forEach((ele) => {
        ids.push(ele.id)
      })
      return ids.join(",")
    },
    showConfirmFlag() {
      return (data) => {
        let tags = {
          text: '',
          type: ''
          return tags
        }
        if (data == 1) {
          tags = {
            text: '待审核',
            type: 'warning'
      },
      showResignationFlag() {
        return (data) => {
          let tags = {
            text: '',
            type: ''
          }
        } else if (data == 2) {
          tags = {
            text: '已审核',
            type: 'success'
          if (data == 1) {
            tags = {
              text: '在职',
              type: 'success'
            }
          } else if (data == 2) {
            tags = {
              text: '已离职',
              type: 'danger'
            }
          }
        } else if (data == 3) {
          tags = {
            text: '未通过',
            type: 'danger'
          }
        } else if (data == 4) {
          tags = {
            text: '待完善',
            type: 'info'
          }
          return tags
        }
      },
        return tags
      }
    },
    showResignationFlag() {
      return (data) => {
        let tags = {
          text: '',
          type: ''
        }
        if (data == 1) {
          tags = {
            text: '在职',
            type: 'success'
      showGender() {
        return (data) => {
          let tags = {
            text: '',
            type: ''
          }
        } else if (data == 2) {
          tags = {
            text: '已离职',
            type: 'danger'
          if (data == 1) {
            tags = {
              text: '男',
              type: 'primary'
            }
          } else if (data == 0) {
            tags = {
              text: '女',
              type: 'primary'
            }
          }
          return tags
        }
      },
        return tags
      }
    },
    showGender() {
      return (data) => {
        let tags = {
          text: '',
          type: ''
        }
        if (data == 1) {
          tags = {
            text: '男',
            type: 'primary'
          }
        } else if (data == 0) {
          tags = {
            text: '女',
            type: 'primary'
          }
        }
        return tags
      }
    },
    decimalProcessing() {
      return (data) => {
        if (data != null) {
          return Number(data).toFixed(6)
        } else {
          return ''
        }
      }
    },
    textDispose() {
      return (row, flag, type) => {
        if (row[flag] || row[type] == null) {
          return row[type]
        } else {
          if (type == 'principalIdCard') {
            return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
      decimalProcessing() {
        return (data) => {
          if (data != null) {
            return Number(data).toFixed(6)
          } else {
            return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
            return ''
          }
        }
      },
      textDispose() {
        return (row, flag, type) => {
          if (row[flag] || row[type] == null) {
            return row[type]
          } else {
            if (type == 'principalIdCard') {
              return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
            } else {
              return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
            }
          }
        }
      }
    }
  },
  methods: {
    handleQueryAlarm(type) {
      this.query.type = type
      this.onLoad(this.page)
    },
    showStringDispose(row, type) {
      row[type] = !row[type]
    },
    methods: {
      handleQueryAlarm(type) {
        this.query.type = type
        this.onLoad(this.page)
      },
      showStringDispose(row, type) {
        row[type] = !row[type]
      },
    locationDispose(data) {
      data = data.split(',')
      locationDispose(data) {
        data = data.split(',')
      return {
        longitude: data[0],
        latitude: data[1],
        location: data[2]
      }
    },
    rowDel(row) {
        return {
          longitude: data[0],
          latitude: data[1],
          location: data[2]
        }
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
@@ -458,182 +482,182 @@
          })
      },
    auditCur(row) {
      this.curAuditRow = row
      this.auditBasePopup = true
    },
      auditCur(row) {
        this.curAuditRow = row
        this.auditBasePopup = true
      },
    ManageTenants(item) {
      this.$refs.BaseAllInfo.initOpen(item)
    },
      ManageTenants(item) {
        this.$refs.BaseAllInfo.initOpen(item)
      },
    rowSave(row, done, loading) {
      if (row.imageUrls.length > 0) {
        var urls = []
        var split = row.imageUrls.split(",").filter(item => item != '')
        split.forEach(url => {
          var names = url.split("jczz/")
          urls.push(names[1])
        })
        row.imageUrls = urls.join(",")
      }
      let label = row.label
      if (row.smallLabel != '') {
        label = label + ',' + row.smallLabel
      }
      delete row.smallLabel
      add({
        ...row,
        label,
        ...this.locationDispose(row.location)
      }).then(
        () => {
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
      rowSave(row, done, loading) {
        if (row.imageUrls.length > 0) {
          var urls = []
          var split = row.imageUrls.split(",").filter(item => item != '')
          split.forEach(url => {
            var names = url.split("jczz/")
            urls.push(names[1])
          })
          done()
        },
        (error) => {
          window.console.log(error)
          loading()
          row.imageUrls = urls.join(",")
        }
      )
    },
    searchReset() {
      this.query = {}
      this.onLoad(this.page)
    },
    searchChange(params, done) {
      this.query = params
      this.page.currentPage = 1
      this.onLoad(this.page, params)
      done()
    },
    selectionChange(list) {
      this.selectionList = list
    },
    selectionClear() {
      this.selectionList = []
      this.$nextTick(() => {
        this.$refs.crud && this.$refs.crud.toggleSelection()
      })
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据")
        return
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids)
        })
        .then(() => {
          this.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!",
          })
          this.$refs.crud.toggleSelection()
        })
    },
        let label = row.label
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        if (this.form.resignationFlag) {
          if (this.form.resignationFlag == 1) {
            this.form.resignationFlag = '在职'
          }
          if (this.form.resignationFlag == 2) {
            this.form.resignationFlag = '已离职'
          }
          // this.form.employerImg = this.form.employerImg.split(",").filter(item => item != '').map(item => website.minioUrl + item).join(',')
        if (row.smallLabel != '') {
          label = label + ',' + row.smallLabel
        }
        done()
      }
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize
    },
    refreshChange() {
      this.onLoad(this.page, this.query)
    },
    onLoad(page, params = {}) {
      this.loading = true
        delete row.smallLabel
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then((res) => {
        const data = res.data.data
        this.page.total = data.total
        this.data = data.records
        this.getPeopleCount();
        this.data.forEach(item => {
          this.$set(item, 'telephoneflag', false)
          this.$set(item, 'idCardflag', false)
          if (item.employerImg && item.employerImg != '' && item.employerImg != null && item.employerImg
            .length) {
            var urls = []
            var names = item.employerImg.split(",").filter(item => item != '')
            names.forEach(name => {
              urls.push(website.minioUrl + name)
        add({
          ...row,
          label,
          ...this.locationDispose(row.location)
        }).then(
          () => {
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            })
            item.employerImg = urls.join(",")
            done()
          },
          (error) => {
            window.console.log(error)
            loading()
          }
        )
      },
      searchReset() {
        this.query = {}
        this.onLoad(this.page)
      },
      searchChange(params, done) {
        this.query = params
        this.page.currentPage = 1
        this.onLoad(this.page, params)
        done()
      },
      selectionChange(list) {
        this.selectionList = list
      },
      selectionClear() {
        this.selectionList = []
        this.$nextTick(() => {
          this.$refs.crud && this.$refs.crud.toggleSelection()
        })
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据")
          return
        }
        this.$confirm("确定将选择数据删除?", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
          .then(() => {
            return remove(this.ids)
          })
          .then(() => {
            this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            })
            this.$refs.crud.toggleSelection()
          })
      },
        this.loading = false
        this.selectionClear()
      })
    },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          if (this.form.resignationFlag) {
            if (this.form.resignationFlag == 1) {
              this.form.resignationFlag = '在职'
            }
            if (this.form.resignationFlag == 2) {
              this.form.resignationFlag = '已离职'
            }
            // this.form.employerImg = this.form.employerImg.split(",").filter(item => item != '').map(item => website.minioUrl + item).join(',')
          }
          done()
        }
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize
      },
      refreshChange() {
        this.onLoad(this.page, this.query)
      },
      onLoad(page, params = {}) {
        this.loading = true
        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then((res) => {
          const data = res.data.data
          this.page.total = data.total
          this.data = data.records
          this.getPeopleCount();
          this.data.forEach(item => {
            this.$set(item, 'telephoneflag', false)
            this.$set(item, 'idCardflag', false)
            if (item.employerImg && item.employerImg != '' && item.employerImg != null && item.employerImg
              .length) {
              var urls = []
              var names = item.employerImg.split(",").filter(item => item != '')
              names.forEach(name => {
                urls.push(website.minioUrl + name)
              })
              item.employerImg = urls.join(",")
            }
          })
          this.loading = false
          this.selectionClear()
        })
      },
    getPeopleCount(params = {}) {
      // 在职的
      // params = {
      //   resignationFlag:1
      // }
      getCount(params).then(res => {
        this.countInfo = res.data.data;
      })
      getPeopleCount(params = {}) {
        // 在职的
        // params = {
        //   resignationFlag:1
        // }
        getCount(params).then(res => {
          this.countInfo = res.data.data;
        })
      }
    }
  }
}
</script>
<style>
.avue-upload__icon {
  line-height: 6;
}
  .avue-upload__icon {
    line-height: 6;
  }
.type-row {
  display: flex;
  padding: 0 0 20px;
}
  .type-row {
    display: flex;
    padding: 0 0 20px;
  }
.type-item {
  padding: 12px 12px;
  background-color: #429FFF;
  color: #fff;
  font-size: 14px;
  margin-right: 30px;
  border-radius: 6px;
  text-align: center;
}
  .type-item {
    padding: 12px 12px;
    background-color: #429FFF;
    color: #fff;
    font-size: 14px;
    margin-right: 30px;
    border-radius: 6px;
    text-align: center;
  }
</style>