保安服务单位许可和备案申请系统-验收版本
liuyg
2021-10-12 b36b15806a0e45777fdc802951a4ddc724b7dc9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<template>
  <basic-container class="hasButTwo">
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="type" slot-scope="{ row }">
        <el-tag :class="row.type != 2 ? 'red' : ''">{{
          row.type != 2 ? "未上传" : "已上传"
        }}</el-tag>
      </template>
      <template slot="downtemplate" slot-scope="{ row }">
        <el-tag
          @click="downTemplates(row.template)"
          class="hand"
          :class="row.template == '' ? 'red' : ''"
          >{{ row.template == "" ? "无模板" : "下载模板" }}</el-tag
        >
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          icon="el-icon-upload2"
          :size="size"
          :type="type"
          @click="upData(row)"
          >上传</el-button
        >
        <el-button
          icon="el-icon-download"
          :size="size"
          :type="type"
          :disabled="row.type != 2"
          @click="dowmData(row)"
          >下载</el-button
        >
      </template>
    </avue-crud>
 
    <el-dialog
      title="附件管理"
      append-to-body
      :visible.sync="attachBox"
      width="555px"
    >
      <avue-form
        ref="form"
        :option="attachOption"
        v-model="attachForm"
        :upload-after="uploadAfter"
      >
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
 
<script>
import { getUseInfor, getTemplate, addUseInfor } from "@/api/resource/attach";
import { mapGetters } from "vuex";
 
export default {
  props: ["type", "opens", "enclosure", "ptype"],
  data() {
    var type = this.type;
    var deptid = this.$route.query.deptId;
    var cardid = this.$store.getters.userInfo.Id;
    return {
      form: {},
      query: {},
      putParam: "",
      loading: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      attachBox: false,
      selectionList: [],
      option: {
        height: 600,
 
        calcHeight: 30,
        tip: false,
        align: "center",
        searchShow: false,
        columnBtn: false,
        menuWidth: 180,
        searchMenuSpan: 6,
        border: false,
        index: true,
        delBtn: false,
        stripe: true,
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "附件名称",
            prop: "originalname",
            overHidden: true,
          },
          {
            label: "附件状态",
            prop: "type",
            width: 110,
            slot: true,
            overHidden: true,
          },
          {
            label: "示范模板",
            prop: "downtemplate",
            width: 110,
            // overHidden: true,
            slot: true,
          },
        ],
      },
      data: [],
      attachForm: {},
      attachOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "拖拽上传",
            prop: "imgUrl5",
            type: "upload",
            span: 12,
            drag: true,
            propsHttp: {
              res: "data",
            },
            tip: "只能上传jpg/png文件,且不超过500kb",
            action:
              // "/api/blade-resource/oss/endpoint/put-file-attach",
              "/api/blade-resource/oss/endpoint/put-file-attach?deptid=&type=" +
              type +
              "&cardid=" +
              cardid,
          },
        ],
      },
      imgSee: false,
      imgUrl: "",
 
      saveIds: [],
      saveLinks: [],
      onceIds: "",
      onceLinks: "",
    };
  },
  computed: {
    ...mapGetters(["permission", "canDoIt"]),
    permissionList() {
      return {
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: this.vaildData(this.permission.attach_delete, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  mounted() {
    // console.log(this.enclosure, "enclosure");
    var flag = false,
      i = 0,
      ind = null;
    this.$store.state.tags.tagList.forEach((item, index) => {
      if (item.label == "附件上传") {
        if (flag == false) {
          ind = index;
          flag = true;
        }
        i++;
      }
    });
    if (i > 1) {
      this.$store.state.tags.tagList.splice(ind, 1);
    }
  },
  methods: {
    upData(val) {
      console.log(val);
      this.onceIds = +val.id - 1 + "";
      this.attachBox = true;
    },
    dowmData(val) {
      console.log(val.down);
      window.open(val.down);
      //
    },
    downTemplates(val) {
      // console.log(val);
      if (val == "") {
        return;
      }
      window.open(val);
      // window.open(`/api/examScore/export-template`);
    },
    handleUpload() {
      this.attachBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(res.link);
      var test = /^http:\/\/.*/;
      if (!test.test(res.link)) {
        this.$message.error("上传失败");
        return;
      }
      this.onceLinks = res.link;
      var haveit = null;
      for (let k in this.saveIds) {
        if (this.saveIds[k] == this.onceIds) {
          // this.saveLinks[k] = this.onceLinks;
          haveit = k;
          break;
        }
      }
      if (haveit != null) {
        this.saveLinks[haveit] = this.onceLinks;
      } else {
        this.saveIds.push(this.onceIds);
        this.saveLinks.push(this.onceLinks);
      }
      console.log(this.saveIds);
      console.log(this.saveLinks);
 
      //  console.log(this.$store.getters.userInfo.Id);
      var params = {
        userid: this.$store.getters.userInfo.Id,
        ptype: this.ptype,
        templateid: this.saveIds.join(","),
        links: this.saveLinks.join(","),
      };
      addUseInfor(params).then((res) => {
        // console.log(res);
        this.$message({
          type: "success",
          message: "操作成功!",
        });
      });
      this.refreshChange();
      this.attachBox = false;
      done();
    },
    handleDownload(row) {
      window.open(`${row.link}`);
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    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();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    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.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      var that = this;
      var data = [];
      console.log(this.$store.getters.userInfo.Id);
      // this.data = this.enclosure;
      params["ptype"] = this.ptype;
      getTemplate(params, 1, 50).then((res) => {
        data = res.data.data.records;
        // console.log(data, "::template");
        params["userid"] = this.$store.getters.userInfo.Id;
        getUseInfor(params).then((res) => {
          var userInfo = res.data.data.records;
          // console.log(userInfo, "::userInfo");
          if (userInfo.length == 0) {
            for (var k in data) {
              data[k]["type"] = 1;
            }
            that.data = data;
            this.saveIds = [];
            this.saveLinks = [];
          } else {
            this.saveIds = userInfo[0].templateid.split(",");
            this.saveLinks = userInfo[0].links.split(",");
            for (let k in data) {
              for (let i in this.saveIds) {
                if (+data[k].id - 1 == this.saveIds[i]) {
                  data[k]["type"] = 2;
                  data[k]["down"] = this.saveLinks[i];
                }
              }
              // data[k]["type"] = 1;
            }
            that.data = data;
          }
        });
      });
    },
 
    seeImages(row) {
      this.imgUrl = "";
      this.imgUrl = "url(" + row.link + ") center center / contain no-repeat";
      console.log(this.imgUrl);
      // this.imgUrl = row.link;
 
      this.imgSee = true;
    },
 
    fileFormat(row) {
      var index = row.link.lastIndexOf(".");
      var ext = row.link.substr(index + 1);
 
      return (
        [
          "png",
          "jpg",
          "jpeg",
          "bmp",
          "gif",
          "webp",
          "psd",
          "svg",
          "tiff",
        ].indexOf(ext.toLowerCase()) == -1
      );
    },
  },
};
</script>
 
<style lang="scss" scoped>
.red {
  border: 1px solid rgba($color: #ff5656, $alpha: 0.3) !important;
  background-color: rgba($color: #ff5151, $alpha: 0.1) !important;
  color: rgba($color: #ff5151, $alpha: 1) !important;
}
.hand:hover {
  cursor: pointer;
}
// .longbut {
//   // background-color: red !important;
//   width: 125px;
// }
// .shortbut {
//   // background-color: green !important;
//   width: 80px;
// }
</style>