保安服务单位许可和备案申请系统
linwe
2024-05-25 0a2191a45a2477e6526ab4b8360cd8feb33c79ad
代码优化
1 files modified
983 ■■■■ changed files
src/components/cardPopup/cardPopup.vue 983 ●●●● patch | view | raw | blame | history
src/components/cardPopup/cardPopup.vue
@@ -50,508 +50,513 @@
</template>
<script>
import {
  mapGetters
} from "vuex";
import {
  add,
  patrolGroupTree,
  selectIn,
  uploadFile
} from "@/api/recordOur/outCardPopup";
import attach from "@/components/attach/attach";
import {
  getList,
  getListre,
  getListrek,
  getListrev,
  getListrel
} from "@/api/permit/permit";
export default {
  components: {
    attach: attach
  },
  props: ["data", "together"],
  data() {
    return {
      htmls: "",
      see: false,
      name: "",
      type: "",
      imgType: "",
      apiName: [],
      forms: 2,
      data0: {},
      obj0: {
        type: 2
      },
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option: {
        emptyBtn: false,
        submitBtn: true,
        gutter: 50,
        column: [{
          labelWidth: 100,
          label: "场所名称",
          prop: "placeName",
          // span: 24,
          rules: [{
            required: true,
            message: "请输入场所名称",
            trigger: "blur"
          }]
        }, {
          labelWidth: 100,
          label: "负责人名称",
          prop: "principal",
          // span: 24,
          rules: [{
            required: true,
            message: "请输入场所负责人姓名",
            trigger: "blur"
          }]
  import {
    mapGetters
  } from "vuex";
  import {
    add,
    patrolGroupTree,
    selectIn,
    uploadFile
  } from "@/api/recordOur/outCardPopup";
  import attach from "@/components/attach/attach";
  import {
    getList,
    getListre,
    getListrek,
    getListrev,
    getListrel
  } from "@/api/permit/permit";
  export default {
    components: {
      attach: attach
    },
    props: ["data", "together"],
    data() {
      return {
        htmls: "",
        see: false,
        name: "",
        type: "",
        imgType: "",
        apiName: [],
        forms: 2,
        data0: {},
        obj0: {
          type: 2
        },
        {
          labelWidth: 100,
          label: "负责人电话",
          prop: "principalPhone",
          // span: 24,
          rules: [{
            required: true,
            message: "请输入场所负责人联系方式",
            trigger: "blur"
          }]
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        {
          labelWidth: 100,
          // width: 160,
          overHidden: true,
          slot: true,
          label: "位置",
          prop: "location",
          type: "map",
          dataType: "string",
          // labelWidth: 120,
          // span: 24,
          value: [117.96646, 28.431002, ""],
          // cascader: ['houseCodeBinds'],
          mapChange: (params) => {
            console.log('高德回调参数', params)
          },
          //高德初始化参数
          params: {
            zoom: 10,
            zoomEnable: false,
            dragEnable: false,
          },
          rules: [{
            required: true,
            message: "请选择地址",
            trigger: "blur",
          },],
        },
        {
          // labelWidth: 100,
          // label: "派出所名称",
          // prop: "pcsName",
          labelWidth: 100,
          overHidden: true,
          label: "派出所名称",
          parent: false,
          prop: "pcsCode",
          // search: true,
          searchSpan: 4,
          searchType: 'input',
          type: "tree",
          dicUrl: "/api/blade-policeStation/policeStation/tree",
          props: {
            label: "name",
            value: "id"
          },
          nodeClick: (data, node, nodeComp) => {
            this.obj0.pcsName = data.name
          },
          // span: 24,
          rules: [{
            required: true,
            message: "请输入派出所名称",
            trigger: "blur"
          }]
        },
        {
          // width: 156,
          labelWidth: 100,
          overHidden: true,
          label: "社区名称",
          parent: false,
          prop: "communityCode",
          // search: true,
          searchSpan: 4,
          searchType: 'input',
          type: "tree",
          dicUrl: "/api/blade-system/region/treeToCommunity?isFiter='1'",
          defaultExpandedKeys: ["361102"],
          props: {
            label: "name",
            value: "id"
          },
          nodeClick: (data, node, nodeComp) => {
            this.obj0.communityName = data.name
          },
          rules: [{
            required: true,
            message: "请选择社区名称",
            trigger: "blur",
          },],
        },
        {
          labelWidth: 100,
          disabled: true,
          // label: "无诈类型",
          // prop: "noFraudType",
          label: "无诈类别",
          prop: "noFraudType",
          align: 'center',
          dicUrl: "/api/blade-system/dict-biz/tree?code=noExplosionCategory",
          props: {
            label: "title",
            value: "key",
          },
          type: 'select',
          search: true,
          searchSpan: 4,
          searchLabelWidth: 96,
          align: 'center'
        },
        ]
      },
      optionFile: {
        emptyBtn: false,
        submitBtn: true,
        gutter: 50,
        column: [
          //   {
          //   label: "附件",
          //   prop: "parentCode",
          //   type: 'upload',
          //   span: 24,
          //   dragFile: true,
          //   // action: action,
          //   rules: [{
          //     required: true,
          //     message: "请上传附件",
          //     trigger: "blur"
          //   }]
          // },
          {
            label: '附件',
            prop: 'fileUrls',
            type: 'upload',
            span: 24,
            hide: true,
            labelWidth: 140,
            multiple: true,
            listType: "text",
            // showFileList: true,
            propsHttp: {
              res: 'data',
              name: "originalName",
              url: "link"
        option: {
          emptyBtn: false,
          submitBtn: true,
          gutter: 50,
          column: [{
              labelWidth: 100,
              label: "场所名称",
              prop: "placeName",
              // span: 24,
              rules: [{
                required: true,
                message: "请输入场所名称",
                trigger: "blur"
              }]
            }, {
              labelWidth: 100,
              label: "负责人名称",
              prop: "principal",
              // span: 24,
              rules: [{
                required: true,
                message: "请输入场所负责人姓名",
                trigger: "blur"
              }]
            },
            data: {
              suffix: 'pdf,ppt,doc,docx'
            {
              labelWidth: 100,
              label: "负责人电话",
              prop: "principalPhone",
              // span: 24,
              rules: [{
                required: true,
                message: "请输入场所负责人联系方式",
                trigger: "blur"
              }]
            },
            action: '/api/blade-resource/oss/endpoint/put-file-attach-suffix',
            rules: [{
              required: true,
              message: "请上传附件",
              trigger: "blur",
            },],
          },
        ],
      },
            {
              labelWidth: 100,
              // width: 160,
              overHidden: true,
              slot: true,
              label: "位置",
              prop: "location",
              type: "map",
              dataType: "string",
              // labelWidth: 120,
              // span: 24,
              value: [117.96646, 28.431002, ""],
              // cascader: ['houseCodeBinds'],
              mapChange: (params) => {
                console.log('高德回调参数', params)
              },
              //高德初始化参数
              params: {
                zoom: 10,
                zoomEnable: false,
                dragEnable: false,
              },
              rules: [{
                required: true,
                message: "请选择地址",
                trigger: "blur",
              }, ],
            },
            {
              // labelWidth: 100,
              // label: "派出所名称",
              // prop: "pcsName",
              labelWidth: 100,
              overHidden: true,
              label: "派出所名称",
              parent: false,
              prop: "pcsCode",
              // search: true,
              searchSpan: 4,
              searchType: 'input',
              type: "tree",
              dicUrl: "/api/blade-policeStation/policeStation/tree",
              props: {
                label: "name",
                value: "id"
              },
              nodeClick: (data, node, nodeComp) => {
                this.obj0.pcsName = data.name
              },
              // span: 24,
              rules: [{
                required: true,
                message: "请输入派出所名称",
                trigger: "blur"
              }]
            },
            {
              // width: 156,
              labelWidth: 100,
              overHidden: true,
              label: "社区名称",
              parent: false,
              prop: "communityCode",
              // search: true,
              searchSpan: 4,
              searchType: 'input',
              type: "tree",
              dicUrl: "/api/blade-system/region/treeToCommunity?isFiter='1'",
              defaultExpandedKeys: ["361102"],
              props: {
                label: "name",
                value: "id"
              },
              nodeClick: (data, node, nodeComp) => {
                this.obj0.communityName = data.name
              },
              rules: [{
                required: true,
                message: "请选择社区名称",
                trigger: "blur",
              }, ],
            },
            {
              labelWidth: 100,
              disabled: true,
              // label: "无诈类型",
              // prop: "noFraudType",
              label: "无诈类别",
              prop: "noFraudType",
              align: 'center',
              dicUrl: "/api/blade-system/dict-biz/tree?code=noExplosionCategory",
              props: {
                label: "title",
                value: "key",
              },
              type: 'select',
              search: true,
              searchSpan: 4,
              searchLabelWidth: 96,
              align: 'center'
            },
          ]
        },
      activeNames: ["1", "2"],
      opens: true,
      active: false,
        optionFile: {
          emptyBtn: false,
          submitBtn: true,
          gutter: 50,
          column: [
            //   {
            //   label: "附件",
            //   prop: "parentCode",
            //   type: 'upload',
            //   span: 24,
            //   dragFile: true,
            //   // action: action,
            //   rules: [{
            //     required: true,
            //     message: "请上传附件",
            //     trigger: "blur"
            //   }]
            // },
            {
              label: '附件',
              prop: 'fileUrls',
              type: 'upload',
              span: 24,
              hide: true,
              labelWidth: 140,
              multiple: true,
              listType: "text",
              // showFileList: true,
              propsHttp: {
                res: 'data',
                name: "originalName",
                url: "link"
              },
              data: {
                suffix: 'pdf,ppt,doc,docx'
              },
              action: '/api/blade-resource/oss/endpoint/put-file-attach-suffix',
              rules: [{
                required: true,
                message: "请上传附件",
                trigger: "blur",
              }, ],
            },
          ],
        },
      OnceChouse: false, //选择武装押运或者保安服务许可
      cardData: [],
      choseType: "",
      overtime: {
        overtimef: "",
        overtimec: ""
      },
      enclosure: [], //附件上传 基础数据
      patrolGroup: [],
      taskPlaceRecordVOList: [],
        activeNames: ["1", "2"],
        opens: true,
        active: false,
    };
  },
  computed: {
    ...mapGetters(["userInfo", "useWhere"])
  },
  watch: {
    useWhere() {
      var d = [];
      // console.log("********6666********" + JSON.stringify(this.useWhere))
      // console.log(this.together, "fromWhere");
      for (var i in this.together) {
        if (this.useWhere == this.together[i].fromWhere) {
          this.OnceChouse = true;
        OnceChouse: false, //选择武装押运或者保安服务许可
        cardData: [],
        choseType: "",
        overtime: {
          overtimef: "",
          overtimec: ""
        },
        enclosure: [], //附件上传 基础数据
        patrolGroup: [],
        taskPlaceRecordVOList: [],
          d.push(this.together[i]);
          // console.log("选择");
        }
      }
      // console.log("**********noFraudType*****************" + JSON.stringify(this.data))
      if (this.OnceChouse) {
        this.choseType = this.useWhere;
        for (var k in this.data) {
          if (this.data[k].type == this.useWhere) {
            d.unshift(this.data[k]);
          }
        }
        this.cardData = d;
        // console.log(this.cardData);
      } else {
        this.see = true;
        // this.openS();
        this.getPatrolGroupTree();
        this.obj0.noFraudType = this.useWhere
        console.table(this.data);
        this.taskPlaceRecordVOList = []
        // console.log(this.data[0].type);
      }
      if (this.useWhere == "close") {
        this.tipover();
      }
    }
  },
  methods: {
    uploadFile(param) {
      console.log("自定义上传", param);
      const formData = new FormData()
      formData.append('file', param.file)
      formData.append('suffix', "pdf,ppt,doc,docx")
      let data = param.data
      uploadFile(formData).then(res => {
        if (res.data.code == 200) {
          this.taskPlaceRecordVOList.push({
            itemId: data.id,
            imageUrls: res.data.data.link
          })
        }
        console.log('上传图片成功' + JSON.stringify(res))
        // console.log('上传图片成功2' + JSON.stringify(this.patrolGroup))
        console.log('上传图片成功2' + JSON.stringify(this.taskPlaceRecordVOList))
      }).catch(response => {
        console.log('图片上传失败')
      })
    },
    handleChange(file, fileList) {
      console.table(fileList)
      // this.fileList = fileList.slice(-3);
    },
    tipchose() {
      this.OnceChouse = false;
      this.openS(this.choseType, this.cardData);
    },
    openS(chose, datas) {
      console.log("****111*****" + JSON.stringify(chose))
      console.log("****222*****" + JSON.stringify(datas))
      var n = chose || this.useWhere;
      this.data = datas || this.data;
      for (var k in this.data) {
        if (n == this.data[k].type) {
          this.see = true;
          this.type = this.data[k].type;
          this.enclosure = this.data[k].enclosure;
          this.overtime = this.data[k].overtime;
          this.imgType = this.data[k].imgType;
          this.htmls = this.data[k].datas.htmls;
          this.apiName = this.data[k].datas.apiName;
          this.name = this.data[k].menuName;
          var d = this.data[k].datas.column;
          this.onLoad(this.page, {}, n, d);
          console.log("已选择type:" + n + "--" + this.name);
          this.convert();
        }
      }
    },
    onLoad(page, params = {}, val, d) {
      params["cardid"] = this.userInfo.Id;
    },
    changeBut(val, d) {
      this.opens = val;
      for (var k in d) {
        d[k]["disabled"] = !this.opens;
      }
      this.option.column = d;
      this.active = true;
    },
    convert: function () {
      var caridid = this.$store.getters.userInfo.Id;
      selectIn(this.apiName[2], caridid, this.type).then(res => {
        var d = res.data.data;
        // console.log(d, "d");
        for (var k in d) {
          this.obj0[k.toLowerCase()] = d[k];
        }
        // console.log(this.obj0, "obj0");
      });
    },
    tip0() {
      this.forms = 2;
    },
    qx() {
      this.tipover();
      this.$store.commit("changeuseWhere", "close");
    },
    tip1up1() {
      this.forms = 2;
    },
    getPatrolGroupTree() {
      let data = {
        childType: 6,
        type: 2
      }
      patrolGroupTree(data).then((res) => {
        // console.log("*****res********" + JSON.stringify(res))
        this.patrolGroup = res.data.data
      });
    },
    tip1() {
      //暂存申请
      var d = {};
      for (var k in this.obj0) {
        for (var i in this.option.column) {
          if (k == this.option.column[i].prop && k != "title0") {
            d[k] = this.obj0[k];
          }
        }
      }
      console.log(d);
      this.data0 = d;
      this.data0.cardid = this.$store.getters.userInfo.Id;
      this.data0.ptype = this.type;
      adds().then(() => {
        this.qx();
        this.$message({
          message: "暂存申请成功",
          type: "success"
        });
      });
    },
    aa(b) {
      console.log(b);
    },
    submit() {
      this.up(0);
    },
    up(val = 1) {
      if (val == 1) {
        this.$refs.form1.submit(); //解决点击提交不能显示那个字段输入错误的问题
        return;
      }
      if (this.obj0.fileUrls) {
        this.obj0.fileUrls = JSON.stringify(this.obj0.fileUrls)
      }
      if (this.obj0.location) {
        let arr = this.obj0.location.split(",")
        this.obj0.lng = arr[0]
        this.obj0.lat = arr[1]
        this.obj0.location = arr[2]
      }
      this.obj0.type = 2
      this.obj0.taskPlaceRecordVOList = this.taskPlaceRecordVOList
      add(this.obj0).then(() => {
        this.qx();
        this.$message({
          message: "提交申请成功",
          type: "success"
        });
        this.$store.commit("changecanDoIt", false);
      });
    },
    getNowTime(form) {
      var DaysToAdd = form;
      var now = new Date();
      var newdate = new Date();
      var newtimems = newdate.getTime() + DaysToAdd * 24 * 60 * 60 * 1000;
      newdate.setTime(newtimems);
      //只得到年月日的
      var time =
        newdate.getFullYear() +
        "-" +
        (newdate.getMonth() + 1) +
        "-" +
        newdate.getDate();
      //得到具体时间
      return time;
    },
    tipover(a, b) {
      if (a == 1) {
        console.log(b);
        var number = false,
          reg = /^[0-9]+.?[0-9]*$/;
        for (var k in b) {
          if (k == "creditcode") {
            if (reg.test(b[k])) {
              number = true;
            } else {
              number = false;
            }
          } else {
            continue;
          }
        }
        return number;
      }
      this.forms = 2;
      this.obj0 = {
        // title0: "保安单位基本信息",
      };
      var d = {};
      this.data0 = d;
      this.active = false;
      this.OnceChouse = false;
    },
    computed: {
      ...mapGetters(["userInfo", "useWhere"])
    },
    watch: {
      useWhere() {
        var d = [];
        // console.log("********6666********" + JSON.stringify(this.useWhere))
        // console.log(this.together, "fromWhere");
        for (var i in this.together) {
          if (this.useWhere == this.together[i].fromWhere) {
            this.OnceChouse = true;
            d.push(this.together[i]);
            // console.log("选择");
          }
        }
        // console.log("**********noFraudType*****************" + JSON.stringify(this.data))
        if (this.OnceChouse) {
          this.choseType = this.useWhere;
          for (var k in this.data) {
            if (this.data[k].type == this.useWhere) {
              d.unshift(this.data[k]);
            }
          }
          this.cardData = d;
          // console.log(this.cardData);
        } else {
          this.see = true;
          // this.openS();
          console.log("********6666********" + JSON.stringify(this.useWhere))
          this.obj0.noFraudType = this.useWhere
          this.getPatrolGroupTree();
          // console.table(this.data);
          this.taskPlaceRecordVOList = []
          // console.log(this.data[0].type);
        }
        if (this.useWhere == "close") {
          this.tipover();
        }
      }
    },
    methods: {
      uploadFile(param) {
        console.log("自定义上传", param);
        const formData = new FormData()
        formData.append('file', param.file)
        formData.append('suffix', "pdf,ppt,doc,docx")
        let data = param.data
        uploadFile(formData).then(res => {
          if (res.data.code == 200) {
            this.taskPlaceRecordVOList.push({
              itemId: data.id,
              imageUrls: res.data.data.link
            })
          }
          console.log('上传图片成功' + JSON.stringify(res))
          // console.log('上传图片成功2' + JSON.stringify(this.patrolGroup))
          console.log('上传图片成功2' + JSON.stringify(this.taskPlaceRecordVOList))
        }).catch(response => {
          console.log('图片上传失败')
        })
      },
      handleChange(file, fileList) {
        console.table(fileList)
        // this.fileList = fileList.slice(-3);
      },
      tipchose() {
        this.OnceChouse = false;
        this.openS(this.choseType, this.cardData);
      },
      openS(chose, datas) {
        console.log("****111*****" + JSON.stringify(chose))
        console.log("****222*****" + JSON.stringify(datas))
        var n = chose || this.useWhere;
        this.data = datas || this.data;
        for (var k in this.data) {
          if (n == this.data[k].type) {
            this.see = true;
            this.type = this.data[k].type;
            this.enclosure = this.data[k].enclosure;
            this.overtime = this.data[k].overtime;
            this.imgType = this.data[k].imgType;
            this.htmls = this.data[k].datas.htmls;
            this.apiName = this.data[k].datas.apiName;
            this.name = this.data[k].menuName;
            var d = this.data[k].datas.column;
            this.onLoad(this.page, {}, n, d);
            console.log("已选择type:" + n + "--" + this.name);
            this.convert();
          }
        }
      },
      onLoad(page, params = {}, val, d) {
        params["cardid"] = this.userInfo.Id;
      },
      changeBut(val, d) {
        this.opens = val;
        for (var k in d) {
          d[k]["disabled"] = !this.opens;
        }
        this.option.column = d;
        this.active = true;
      },
      convert: function() {
        var caridid = this.$store.getters.userInfo.Id;
        selectIn(this.apiName[2], caridid, this.type).then(res => {
          var d = res.data.data;
          // console.log(d, "d");
          for (var k in d) {
            this.obj0[k.toLowerCase()] = d[k];
          }
          // console.log(this.obj0, "obj0");
        });
      },
      tip0() {
        this.forms = 2;
      },
      qx() {
        this.tipover();
        this.$store.commit("changeuseWhere", "close");
      },
      tip1up1() {
        this.forms = 2;
      },
      getPatrolGroupTree() {
        if (this.obj0.noFraudType && this.obj0.noFraudType == 'close') {
          return
        }
        let data = {
          childType: this.obj0.noFraudType,
          type: 2
        }
        patrolGroupTree(data).then((res) => {
          // console.log("*****res********" + JSON.stringify(res))
          this.patrolGroup = res.data.data
        });
      },
      tip1() {
        //暂存申请
        var d = {};
        for (var k in this.obj0) {
          for (var i in this.option.column) {
            if (k == this.option.column[i].prop && k != "title0") {
              d[k] = this.obj0[k];
            }
          }
        }
        console.log(d);
        this.data0 = d;
        this.data0.cardid = this.$store.getters.userInfo.Id;
        this.data0.ptype = this.type;
        adds().then(() => {
          this.qx();
          this.$message({
            message: "暂存申请成功",
            type: "success"
          });
        });
      },
      aa(b) {
        console.log(b);
      },
      submit() {
        this.up(0);
      },
      up(val = 1) {
        if (val == 1) {
          this.$refs.form1.submit(); //解决点击提交不能显示那个字段输入错误的问题
          return;
        }
        if (this.obj0.fileUrls) {
          this.obj0.fileUrls = JSON.stringify(this.obj0.fileUrls)
        }
        if (this.obj0.location) {
          let arr = this.obj0.location.split(",")
          this.obj0.lng = arr[0]
          this.obj0.lat = arr[1]
          this.obj0.location = arr[2]
        }
        this.obj0.type = 2
        this.obj0.taskPlaceRecordVOList = this.taskPlaceRecordVOList
        add(this.obj0).then(() => {
          this.qx();
          this.$message({
            message: "提交申请成功",
            type: "success"
          });
          this.$store.commit("changecanDoIt", false);
        });
      },
      getNowTime(form) {
        var DaysToAdd = form;
        var now = new Date();
        var newdate = new Date();
        var newtimems = newdate.getTime() + DaysToAdd * 24 * 60 * 60 * 1000;
        newdate.setTime(newtimems);
        //只得到年月日的
        var time =
          newdate.getFullYear() +
          "-" +
          (newdate.getMonth() + 1) +
          "-" +
          newdate.getDate();
        //得到具体时间
        return time;
      },
      tipover(a, b) {
        if (a == 1) {
          console.log(b);
          var number = false,
            reg = /^[0-9]+.?[0-9]*$/;
          for (var k in b) {
            if (k == "creditcode") {
              if (reg.test(b[k])) {
                number = true;
              } else {
                number = false;
              }
            } else {
              continue;
            }
          }
          return number;
        }
        this.forms = 2;
        this.obj0 = {
          // title0: "保安单位基本信息",
        };
        var d = {};
        this.data0 = d;
        this.active = false;
        this.OnceChouse = false;
      }
    }
  }
};
  };
</script>
<style lang="scss">
.attach_row {
  display: flex;
  border: 0.2px solid rgba(221, 223, 229, 0.5);
  height: 54px;
  .attach_row_title {
    width: 85%;
    border-right: 0.2px solid rgba(221, 223, 229, 0.5);
  .attach_row {
    display: flex;
    justify-content: left;
    align-items: center;
    margin-left: 12px;
  }
    border: 0.2px solid rgba(221, 223, 229, 0.5);
    height: 54px;
  .attach_row_btn {
    width: 15%;
    margin: 10px;
    display: flex;
    justify-content: center;
    .attach_row_title {
      width: 85%;
      border-right: 0.2px solid rgba(221, 223, 229, 0.5);
      display: flex;
      justify-content: left;
      align-items: center;
      margin-left: 12px;
    }
    .attach_row_btn {
      width: 15%;
      margin: 10px;
      display: flex;
      justify-content: center;
    }
  }
}
</style>
</style>