dialog.des.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="rule-type">
  3. <DialogCom
  4. :title="id ? '安全责任书存档记录详情' : '新增安全责任书存档记录'"
  5. :visible.sync="isShow"
  6. @close="onHide"
  7. width="800px"
  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. <el-table
  82. :data="tableData"
  83. style="width: 100%; margin-top: 10px"
  84. height="500px"
  85. >
  86. <el-table-column prop="names" label="签署人">
  87. <template slot-scope="scope">
  88. <template v-for="item in scope.row.names">
  89. {{ item }}
  90. <br />
  91. </template>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="time" label="签署时间">
  95. <template slot-scope="r">
  96. {{
  97. r.row.time ? dayjs(r.row.time).format("YYYY年-MM月-DD日") : ""
  98. }}
  99. </template>
  100. </el-table-column>
  101. <el-table-column prop="files" label="签署文件">
  102. <template slot-scope="r">
  103. <el-image
  104. v-for="(image, index) in r.row.files.split(',')"
  105. :key="index"
  106. style="width: 50px; height: 50px"
  107. :src="image"
  108. :preview-src-list="r.row.files.split(',')"
  109. v-if="index === 0"
  110. fit="contain"
  111. ></el-image>
  112. </template>
  113. </el-table-column>
  114. <el-table-column prop="names" label="操作" v-if="false">
  115. <template v-slot="{ row }">
  116. <el-button type="text" @click="removeRow(row)">删除</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. </div>
  121. <div slot="footer" class="dialog-footer" style="margin-top: 10px">
  122. <el-button @click="isShow = false">确定</el-button>
  123. <!-- <el-button type="primary" @click="onSubmit">确定</el-button> -->
  124. </div>
  125. </DialogCom>
  126. <DialogSelect ref="DialogSelect" @success="getSign"></DialogSelect>
  127. </div>
  128. </template>
  129. <script>
  130. import { mapState, mapMutations } from "vuex";
  131. import { getLabel } from "@/views/commonOption.js";
  132. import {
  133. listSafetyBook,
  134. getSafetyBook,
  135. editOrAdd,
  136. delSafetyBook,
  137. } from "@/api/safetyBook/index";
  138. import { deptTreeSelect } from "@/api/system/public";
  139. import DialogSelect from "./dialog.sign";
  140. import dayjs from "dayjs";
  141. export default {
  142. dicts: ["safety_book_type"],
  143. data() {
  144. return {
  145. labelStyle: {
  146. color: "#000",
  147. "text-align": "center",
  148. height: "40px",
  149. "min-width": "150px",
  150. "word-break": "keep-all",
  151. },
  152. content_style: {
  153. "text-align": "left",
  154. "min-width": "150px",
  155. "word-break": "break-all",
  156. },
  157. id: null,
  158. isShow: false,
  159. timeClearable: true,
  160. formData: this.reset(),
  161. tableData: [],
  162. //修改新增中的机构树
  163. deptOptions: [],
  164. formDataRules: {
  165. orgId: [{ required: true, message: "请选择签署责任人所在机构" }],
  166. type: [{ required: true, message: "请选择签署责任书类型" }],
  167. year: [{ required: true, message: "请选择所属年度" }],
  168. },
  169. };
  170. },
  171. watch: {},
  172. computed: {
  173. ...mapState([]),
  174. },
  175. methods: {
  176. getLabel,
  177. ...mapMutations([]),
  178. dayjs,
  179. //添加签署后回调
  180. getSign(data) {
  181. this.tableData.push(data);
  182. // console.log(data, "ddd");
  183. },
  184. //新增签署
  185. openSelect() {
  186. this.$refs.DialogSelect.show();
  187. },
  188. /** 查询机构树数据 */
  189. getDeptTree() {
  190. deptTreeSelect().then((response) => {
  191. this.deptOptions = response.data;
  192. });
  193. },
  194. /** treeSelect组件自定义数据*/
  195. tenantIdnormalizer(node, instanceId) {
  196. if (node.children && !node.children.length) {
  197. delete node.children;
  198. }
  199. return {
  200. id: node.id,
  201. label: node.shortName,
  202. children: node.children,
  203. };
  204. },
  205. removeRow(row) {
  206. this.tableData = this.tableData.filter((item) => item !== row);
  207. },
  208. reset() {
  209. return {
  210. id: null,
  211. type: null,
  212. year: null,
  213. };
  214. },
  215. async refresh(id) {
  216. if (id != null && id != undefined) {
  217. await getSafetyBook(id).then((res) => {
  218. // console.log(res.data,"res")
  219. this.formData = res.data;
  220. this.tableData = res.data.bookUsers;
  221. });
  222. }
  223. },
  224. async show(id) {
  225. // console.log(id, "id");
  226. this.getDeptTree();
  227. this.formData = this.reset();
  228. this.tableData = [];
  229. this.id = id;
  230. await this.refresh(id);
  231. this.isShow = true;
  232. },
  233. // 事件
  234. onHide() {
  235. this.formData = this.reset();
  236. this.$refs.form.resetFields();
  237. },
  238. onSubmit() {
  239. console.log(this.formData, "this.formData");
  240. this.$refs.form.validate(async (isValidate) => {
  241. if (!isValidate) return;
  242. this.formData.bookUsers = this.tableData;
  243. await editOrAdd(this.formData);
  244. this.$emit("success");
  245. this.isShow = false;
  246. });
  247. },
  248. // 事件
  249. //apimark//
  250. },
  251. mounted() {},
  252. components: { DialogSelect },
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .brand_info {
  257. .el-form {
  258. width: 600px;
  259. padding-top: 40px;
  260. }
  261. }
  262. </style>