| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <template>
- <div class="rule-type">
- <DialogCom
- :title="id ? '编辑安全责任书存档记录' : '新增安全责任书存档记录'"
- :visible.sync="isShow"
- @close="onHide"
- width="1200px"
- >
- <div class="page-body">
- <el-form
- :model="formData"
- :rules="formDataRules"
- size="small"
- ref="form"
- label-position="right"
- label-width="180px"
- label-prefix=":"
- >
- <el-form-item prop="orgId" label="乙方所属机构:">
- <tree-select
- v-model="formData.orgId"
- :options="deptOptions"
- :show-count="true"
- :normalizer="tenantIdnormalizer"
- :props="{ checkStrictly: true, label: 'shortName' }"
- placeholder="请选择乙方所属机构"
- />
- </el-form-item>
- <el-form-item label="所属年度:" prop="year">
- <el-date-picker
- v-model="formData.year"
- :clearable="timeClearable"
- type="year"
- placeholder="请选择责任书所属年度"
- value-format="yyyy"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item prop="type" label="签署责任书类型:">
- <el-select
- v-model="formData.type"
- style="width: 100%"
- placeholder="请选择签署责任书类型"
- >
- <el-option
- v-for="dict in dict.type.safety_book_type"
- :key="dict.value"
- :label="dict.label"
- :value="`${dict.value}`"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <el-button @click="openSelect">上传签署文件</el-button>
- <el-table
- :data="tableData"
- style="width: 100%; margin-top: 10px"
- height="500px"
- >
- <!-- <el-table-column prop="names" label="签署人">
- <template slot-scope="scope">
- <template v-for="item in scope.row.names">
- {{ item }}
- <br />
- </template>
- </template>
- </el-table-column> -->
- <el-table-column prop="partyA" label="甲方"> </el-table-column>
- <el-table-column prop="partyAOrg" label="甲方机构"> </el-table-column>
- <el-table-column prop="partyB" label="乙方"> </el-table-column>
- <el-table-column prop="partyBOrg" label="乙方机构"> </el-table-column>
- <el-table-column prop="time" label="签署时间">
- <template slot-scope="r">
- {{ r.row.time ? dayjs(r.row.time).format("YYYY年MM月DD日") : "" }}
- </template>
- </el-table-column>
- <el-table-column prop="files" width="400px" label="签署文件">
- <template slot-scope="r">
- <div
- v-for="(file, index) in r.row.files"
- :key="index"
- class="container"
- >
- <el-image
- class="item"
- v-if="isPic(file.url)"
- :src="file.url"
- :preview-src-list="[file.url]"
- fit="contain"
- ></el-image>
- <div v-else="isPic(file.url)">
- <el-link :href="file.url" :underline="false" target="_blank">
- <span class="el-icon-document"> {{ file.name }} </span>
- </el-link>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="names" label="操作">
- <template v-slot="{ row }">
- <el-button type="text" @click="editII(row)">编辑</el-button>
- <el-button type="text" @click="removeRow(row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div slot="footer" class="dialog-footer" style="margin-top: 10px">
- <el-button @click="isShow = false">取消</el-button>
- <el-button type="primary" @click="onSubmit">确定</el-button>
- </div>
- </DialogCom>
- <DialogSelect ref="DialogSelect" @success="getSign"></DialogSelect>
- </div>
- </template>
- <script>
- import { mapState, mapMutations } from "vuex";
- import { mapGetters } from "vuex";
- import {
- listSafetyBook,
- getSafetyBook,
- editOrAdd,
- delSafetyBook,
- } from "@/api/safetyBook/index";
- import { deptTreeSelect } from "@/api/system/public";
- import DialogSelect from "./dialog.sign";
- import dayjs from "dayjs";
- export default {
- dicts: ["safety_book_type"],
- data() {
- return {
- id: null,
- isShow: false,
- timeClearable: true,
- formData: this.reset(),
- tableData: [],
- //修改新增中的机构树
- deptOptions: [],
- formDataRules: {
- orgId: [
- {
- required: true,
- message: "请选择签署责任人所在机构",
- trigger: "blur",
- },
- ],
- type: [{ required: true, message: "请选择签署责任书类型" }],
- year: [{ required: true, message: "请选择所属年度" }],
- },
- };
- },
- watch: {},
- computed: {
- ...mapState([]),
- ...mapGetters(["orgId", "orgName"]),
- },
- methods: {
- ...mapMutations([]),
- isPic(url) {
- if (url.endsWith("jpg") || url.endsWith("png")) {
- return true;
- }
- return false;
- },
- // getUrl(files) {
- // console.log(files, "eeee");
- // let arr = [];
- // files.forEach((item) => {
- // arr.push(JSON.parse(item));
- // });
- // console.log(
- // arr.map((e) => e.url),
- // "dataaa"
- // );
- // // return arr.map((e) => e.url);
- // return arr;
- // },
- // showHow(files) {
- // let file = files.split(",");
- // if (file[0].endsWith(".jpg")) {
- // return true;
- // }
- // return false;
- // },
- dayjs,
- //添加签署后回调
- getSign(data, row) {
- this.tableData = this.tableData.filter((item) => item !== row);
- this.tableData.push(data);
- // console.log(data, "ddd");
- // console.log(row, "row");
- },
- editII(row) {
- // console.log(row,"wwwwwww")
- this.$refs.DialogSelect.show(row);
- // this.tableData = this.tableData.filter((item) => item !== row);
- },
- //新增签署
- openSelect() {
- this.$refs.DialogSelect.show();
- },
- /** 查询机构树数据 */
- getDeptTree() {
- deptTreeSelect().then((response) => {
- this.deptOptions = response.data;
- });
- },
- /** treeSelect组件自定义数据*/
- tenantIdnormalizer(node, instanceId) {
- if (node.children && !node.children.length) {
- delete node.children;
- }
- return {
- id: node.id,
- label: node.shortName,
- children: node.children,
- };
- },
- removeRow(row) {
- this.$modal
- .confirm("是否确认删除?")
- .then(function () {})
- .then(() => {
- this.tableData = this.tableData.filter((item) => item !== row);
- this.$modal.msgSuccess("删除成功");
- });
- // this.tableData.splice(index, 1);
-
- },
- reset() {
- return {
- id: null,
- type: null,
- year: null,
- };
- },
- async refresh(id) {
- if (id != null && id != undefined) {
- await getSafetyBook(id).then((res) => {
- // console.log(res.data,"res")
- this.formData = res.data;
- this.tableData = res.data.bookUsers;
- });
- }
- },
- async show(id) {
- // console.log(id, "id");
- this.getDeptTree();
- this.formData = this.reset();
- this.tableData = [];
- this.id = id;
- await this.refresh(id);
- if (id) {
- } else {
- // console.log(this.orgId,"this.orgId")
- this.formData.orgId = this.orgId;
- }
- this.isShow = true;
- },
- // 事件
- onHide() {
- this.formData = this.reset();
- this.$refs.form.resetFields();
- },
- onSubmit() {
- // console.log(this.formData,"this.formData")
- this.$refs.form.validate(async (isValidate) => {
- if (!isValidate) return;
- this.formData.bookUsers = this.tableData;
- await editOrAdd(this.formData);
- this.$emit("success");
- this.isShow = false;
- });
- },
- // 事件
- //apimark//
- },
- mounted() {},
- components: { DialogSelect },
- };
- </script>
- <style lang="scss" scoped>
- .brand_info {
- .el-form {
- width: 600px;
- padding-top: 40px;
- }
- }
- .container {
- width: 50px;
- height: 50px;
- float: left;
- .item {
- width: 100%;
- height: 100%;
- }
- .item img {
- width: 100% !important;
- object-fit: cover !important;
- }
- }
- </style>
|