dialog.des.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class="rule-type">
  3. <DialogCom
  4. :title="id ? '安全责任书存档记录详情' : '新增安全责任书存档记录'"
  5. :visible.sync="isShow"
  6. @close="onHide"
  7. width="50%"
  8. >
  9. <div class="page-body">
  10. <el-form
  11. :model="formData"
  12. :rules="formDataRules"
  13. size="small"
  14. ref="form"
  15. label-position="right"
  16. label-width="180px"
  17. label-prefix=":"
  18. >
  19. <el-descriptions
  20. class="margin-top"
  21. :column="1"
  22. size="medium"
  23. border
  24. :label-style="labelStyle"
  25. :contentStyle="content_style"
  26. >
  27. <el-descriptions-item
  28. labelClassName="gx_info_label"
  29. label="签署人所在机构"
  30. >
  31. {{ formData.orgName }}
  32. </el-descriptions-item>
  33. <!-- <el-form-item prop="orgName" label="签署人所在机构:" >
  34. <el-input
  35. :readonly="true"
  36. v-model="formData.orgName"
  37. :disabled="true"
  38. ></el-input>
  39. </el-form-item> -->
  40. <el-descriptions-item
  41. labelClassName="gx_info_label"
  42. label="所属年度"
  43. >
  44. {{ formData.year }}
  45. </el-descriptions-item>
  46. <!-- <el-form-item label="所属年度" prop="year">
  47. <el-date-picker
  48. :disabled="true"
  49. v-model="formData.year"
  50. :clearable="timeClearable"
  51. type="year"
  52. placeholder="请选择责任书所属年度"
  53. value-format="yyyy"
  54. >
  55. </el-date-picker>
  56. </el-form-item> -->
  57. <el-descriptions-item
  58. labelClassName="gx_info_label"
  59. label="签署责任书类型"
  60. >
  61. {{ getLabel(dict.type.safety_book_type, formData.type) }}
  62. </el-descriptions-item>
  63. <!-- <el-form-item prop="type" label="签署责任书类型:">
  64. <el-select
  65. :disabled="true"
  66. v-model="formData.type"
  67. style="width: 100%"
  68. placeholder="请选择签署责任书类型"
  69. >
  70. <el-option
  71. v-for="dict in dict.type.safety_book_type"
  72. :key="dict.value"
  73. :label="dict.label"
  74. :value="`${dict.value}`"
  75. ></el-option>
  76. </el-select>
  77. </el-form-item> -->
  78. </el-descriptions>
  79. </el-form>
  80. <el-button @click="openSelect" v-if="false">上传签署文件</el-button>
  81. <div class="extend_mod">
  82. <el-table
  83. :data="tableData"
  84. style="width: 100%; margin-top: 10px"
  85. height="500px"
  86. border
  87. >
  88. <!-- <el-table-column prop="names" label="签署人">
  89. <template slot-scope="scope">
  90. <template v-for="item in scope.row.names">
  91. {{ item }}
  92. <br />
  93. </template>
  94. </template>
  95. </el-table-column> -->
  96. <el-table-column prop="partyA" label="甲方"> </el-table-column>
  97. <el-table-column prop="partyAOrg" label="甲方机构"> </el-table-column>
  98. <el-table-column prop="partyB" label="乙方"> </el-table-column>
  99. <el-table-column prop="partyBOrg" label="乙方机构"> </el-table-column>
  100. <el-table-column prop="time" label="签署时间">
  101. <template slot-scope="r">
  102. {{ r.row.time ? dayjs(r.row.time).format("YYYY年MM月DD日") : "" }}
  103. </template>
  104. </el-table-column>
  105. <el-table-column prop="files" width="400px" label="签署文件">
  106. <template slot-scope="r">
  107. <div
  108. v-for="(file, index) in r.row.files"
  109. :key="index"
  110. class="container"
  111. >
  112. <el-image
  113. class="item"
  114. v-if="isPic(file.url)"
  115. :src="file.url"
  116. :preview-src-list="[file.url]"
  117. fit="contain"
  118. ></el-image>
  119. <div v-else="isPic(file.url)">
  120. <el-link :href="file.url" :underline="false" target="_blank">
  121. <span class="el-icon-document"> {{ file.name }} </span>
  122. </el-link>
  123. </div>
  124. </div>
  125. </template>
  126. </el-table-column>
  127. <el-table-column prop="names" label="操作" v-if="false">
  128. <template v-slot="{ row }">
  129. <el-button type="text" @click="removeRow(row)">删除</el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. </div>
  134. </div>
  135. <div slot="footer" class="dialog-footer" style="margin-top: 10px">
  136. <el-button @click="isShow = false">确定</el-button>
  137. <!-- <el-button type="primary" @click="onSubmit">确定</el-button> -->
  138. </div>
  139. </DialogCom>
  140. <DialogSelect ref="DialogSelect" @success="getSign"></DialogSelect>
  141. </div>
  142. </template>
  143. <script>
  144. import { mapState, mapMutations } from "vuex";
  145. import { getLabel } from "@/views/commonOption.js";
  146. import {
  147. listSafetyBook,
  148. getSafetyBook,
  149. editOrAdd,
  150. delSafetyBook,
  151. } from "@/api/safetyBook/index";
  152. import { deptTreeSelect } from "@/api/system/public";
  153. import DialogSelect from "./dialog.sign";
  154. import dayjs from "dayjs";
  155. export default {
  156. dicts: ["safety_book_type"],
  157. data() {
  158. return {
  159. labelStyle: {
  160. color: "#000",
  161. "text-align": "center",
  162. height: "40px",
  163. "min-width": "150px",
  164. "word-break": "keep-all",
  165. },
  166. content_style: {
  167. "text-align": "left",
  168. "min-width": "150px",
  169. "word-break": "break-all",
  170. },
  171. id: null,
  172. isShow: false,
  173. timeClearable: true,
  174. formData: this.reset(),
  175. tableData: [],
  176. //修改新增中的机构树
  177. deptOptions: [],
  178. formDataRules: {
  179. orgId: [{ required: true, message: "请选择签署责任人所在机构" }],
  180. type: [{ required: true, message: "请选择签署责任书类型" }],
  181. year: [{ required: true, message: "请选择所属年度" }],
  182. },
  183. };
  184. },
  185. watch: {},
  186. computed: {
  187. ...mapState([]),
  188. },
  189. methods: {
  190. isPic(url) {
  191. if (url.endsWith("jpg")||url.endsWith("png")) {
  192. return true;
  193. }
  194. return false;
  195. },
  196. getLabel,
  197. ...mapMutations([]),
  198. dayjs,
  199. //添加签署后回调
  200. getSign(data) {
  201. this.tableData.push(data);
  202. // console.log(data, "ddd");
  203. },
  204. //新增签署
  205. openSelect() {
  206. this.$refs.DialogSelect.show();
  207. },
  208. /** 查询机构树数据 */
  209. getDeptTree() {
  210. deptTreeSelect().then((response) => {
  211. this.deptOptions = response.data;
  212. });
  213. },
  214. /** treeSelect组件自定义数据*/
  215. tenantIdnormalizer(node, instanceId) {
  216. if (node.children && !node.children.length) {
  217. delete node.children;
  218. }
  219. return {
  220. id: node.id,
  221. label: node.shortName,
  222. children: node.children,
  223. };
  224. },
  225. removeRow(row) {
  226. this.tableData = this.tableData.filter((item) => item !== row);
  227. },
  228. reset() {
  229. return {
  230. id: null,
  231. type: null,
  232. year: null,
  233. };
  234. },
  235. async refresh(id) {
  236. if (id != null && id != undefined) {
  237. await getSafetyBook(id).then((res) => {
  238. // console.log(res.data,"res")
  239. this.formData = res.data;
  240. this.tableData = res.data.bookUsers;
  241. });
  242. }
  243. },
  244. async show(id) {
  245. // console.log(id, "id");
  246. this.getDeptTree();
  247. this.formData = this.reset();
  248. this.tableData = [];
  249. this.id = id;
  250. await this.refresh(id);
  251. this.isShow = true;
  252. },
  253. // 事件
  254. onHide() {
  255. this.formData = this.reset();
  256. this.$refs.form.resetFields();
  257. },
  258. onSubmit() {
  259. console.log(this.formData, "this.formData");
  260. this.$refs.form.validate(async (isValidate) => {
  261. if (!isValidate) return;
  262. this.formData.bookUsers = this.tableData;
  263. await editOrAdd(this.formData);
  264. this.$emit("success");
  265. this.isShow = false;
  266. });
  267. },
  268. // 事件
  269. //apimark//
  270. },
  271. mounted() {},
  272. components: { DialogSelect },
  273. };
  274. </script>
  275. <style lang="scss" scoped>
  276. .brand_info {
  277. .el-form {
  278. width: 600px;
  279. padding-top: 40px;
  280. }
  281. }
  282. .container {
  283. width:50px;
  284. height: 50px;
  285. float: left;
  286. .item {
  287. width:100%;
  288. height: 100%;
  289. }
  290. .item img {
  291. width: 100% !important;
  292. object-fit: cover !important;
  293. }
  294. }
  295. </style>