sendDialog.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <el-form ref="form" :model="form" label-width="82px" :disabled="true">
  4. <el-row :gutter="15">
  5. <el-col :span="6">
  6. <el-form-item label="主题" prop="name">
  7. <el-input v-model="form.name"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="6">
  11. <el-form-item label="发布人" prop="releaseUserName">
  12. <el-input v-model="form.releaseUserName"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="12">
  16. <el-form-item label="发布时间" prop="releaseTime">
  17. <el-date-picker
  18. v-model="form.releaseTime"
  19. type="datetime"
  20. format="yyyy-MM-dd HH:mm:ss"
  21. value-format="yyyy-MM-dd HH:mm:ss"
  22. style="width: 60%"
  23. >
  24. </el-date-picker>
  25. <el-checkbox
  26. style="margin-left: 5px"
  27. v-model="form.isTimeRelease"
  28. :true-label="1"
  29. :false-label="0"
  30. >按照发布时间进行计划发布</el-checkbox
  31. >
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="6">
  35. <el-form-item label="失效时间" prop="failureTime">
  36. <el-date-picker
  37. v-model="form.failureTime"
  38. type="datetime"
  39. format="yyyy-MM-dd HH:mm:ss"
  40. value-format="yyyy-MM-dd HH:mm:ss"
  41. style="width: 100%"
  42. >
  43. </el-date-picker>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="12">
  47. <el-form-item label="创建时间" prop="createTime">
  48. <el-input v-model="form.createTime" style="width: 60%"> </el-input>
  49. <el-checkbox
  50. style="margin-left: 5px"
  51. v-model="form.isAuthority"
  52. :true-label="1"
  53. :false-label="0"
  54. >到失效时间自动回收权限</el-checkbox
  55. >
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="24">
  59. <el-form-item label="发布说明" prop="remark">
  60. <el-input v-model="form.remark" type="textarea"></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="24">
  64. <el-form-item label="发布文档" prop="fileList">
  65. <ele-pro-table
  66. ref="table"
  67. :columns="columns"
  68. :datasource="fileList"
  69. tool-class="ele-toolbar-form"
  70. cache-key="systemOrgUserTable"
  71. :needPage="false"
  72. >
  73. <template v-slot:action="{ row }">
  74. <el-link
  75. type="primary"
  76. :underline="false"
  77. icon="el-icon-edit"
  78. @click="browseOpen(row, 1)"
  79. v-if="['docx', 'pdf', 'doc'].includes(row.storagePath[0]?.type)"
  80. >
  81. 签章
  82. </el-link>
  83. <el-link
  84. type="primary"
  85. :underline="false"
  86. icon="el-icon-edit"
  87. @click="browseOpen(row, 2)"
  88. v-if="
  89. !['docx', 'pdf', 'doc'].includes(row.storagePath[0]?.type)
  90. "
  91. >
  92. 预览
  93. </el-link>
  94. </template>
  95. </ele-pro-table>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="24">
  99. <el-form-item label="通知用户" prop="storagePath">
  100. <power
  101. height="200px"
  102. :powerArr="powerArr"
  103. :isSave="false"
  104. ref="powerRef"
  105. />
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <sealManagement ref="sealManagementRef" @save="save"></sealManagement>
  110. <browse ref="browseRef"></browse>
  111. </el-form>
  112. </template>
  113. <script>
  114. import power from './power.vue';
  115. import {
  116. sendGetById,
  117. fileUpdateAPI,
  118. getById
  119. } from '@/api/bpm/components/doc';
  120. import { uploadFileNew } from '@/components/addDoc/api/index.js';
  121. import sealManagement from '@/components/addDoc/sealManagement.vue';
  122. import browse from '@/components/addDoc/browse.vue';
  123. import { usageRecordAdd } from '@/api/bpm/components/sealManagement';
  124. const defaultForm = {
  125. name: '', //名称
  126. fileList: [], //文档集合json
  127. userAuthority: [], //用户权限集合json
  128. releaseTime: '', //发布时间
  129. failureTime: '', //失效时间
  130. isAuthority: '', //是否回收权限 0 1
  131. remark: ''
  132. };
  133. export default {
  134. components: { power, browse, sealManagement },
  135. props: {
  136. businessId: {
  137. default: ''
  138. }
  139. },
  140. data() {
  141. return {
  142. fileList: [],
  143. form: {
  144. ...defaultForm
  145. },
  146. columns: [
  147. {
  148. label: '编码',
  149. prop: 'code',
  150. width: 180,
  151. align: 'center',
  152. fixed: 'left',
  153. showOverflowTooltip: true
  154. },
  155. {
  156. prop: 'name',
  157. label: '文档名称',
  158. align: 'center',
  159. slot: 'name',
  160. showOverflowTooltip: true,
  161. minWidth: 200
  162. },
  163. {
  164. prop: 'storagePath',
  165. label: '文件名称',
  166. align: 'center',
  167. showOverflowTooltip: true,
  168. minWidth: 200,
  169. formatter: (_row, _column, cellValue) => {
  170. return cellValue[0]?.name;
  171. }
  172. },
  173. {
  174. prop: 'version',
  175. label: '版本',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 100
  179. },
  180. {
  181. prop: 'createUserName',
  182. label: '创建人',
  183. align: 'center',
  184. showOverflowTooltip: true,
  185. minWidth: 100
  186. },
  187. {
  188. prop: 'createTime',
  189. label: '创建时间',
  190. align: 'center',
  191. showOverflowTooltip: true,
  192. minWidth: 160,
  193. formatter: (_row, _column, cellValue) => {
  194. return this.$util.toDateString(cellValue);
  195. }
  196. },
  197. {
  198. prop: 'updateUserName',
  199. label: '修改人',
  200. align: 'center',
  201. showOverflowTooltip: true,
  202. minWidth: 100
  203. },
  204. {
  205. prop: 'updateTime',
  206. label: '修改时间',
  207. align: 'center',
  208. showOverflowTooltip: true,
  209. minWidth: 160
  210. },
  211. {
  212. prop: 'sizeUnit',
  213. label: '文档大小',
  214. align: 'center',
  215. showOverflowTooltip: true,
  216. minWidth: 100
  217. },
  218. {
  219. prop: '',
  220. label: '状态',
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. minWidth: 100
  224. },
  225. {
  226. columnKey: 'action',
  227. label: '操作',
  228. width: 150,
  229. align: 'center',
  230. resizable: false,
  231. slot: 'action',
  232. showOverflowTooltip: true,
  233. fixed: 'right'
  234. }
  235. ],
  236. powerArr: [
  237. { name: 'visible', label: '可见' },
  238. { name: 'check', label: '查看' },
  239. { name: 'browse', label: '浏览' },
  240. { name: 'download', label: '下载' },
  241. { name: 'print', label: '打印' }
  242. ]
  243. };
  244. },
  245. computed: {
  246. // 是否开启响应式布局
  247. styleResponsive() {
  248. return this.$store.state.theme.styleResponsive;
  249. }
  250. },
  251. created() {
  252. this.init();
  253. },
  254. methods: {
  255. save({ pdfFile, id, droppedImages }) {
  256. let fileDataIndex = this.fileList.findIndex((item) => item.id == id);
  257. this.$set(this.fileList[fileDataIndex], 'pdfFile', pdfFile);
  258. this.$set(this.fileList[fileDataIndex], 'droppedImages', droppedImages);
  259. },
  260. async getTableValue() {
  261. // 处理包含 pdfFile 的文件,上传并更新文档地址
  262. const uploadPromises = this.fileList
  263. .filter((item) => item.pdfFile)
  264. .map(async (item) => {
  265. // 上传 PDF 文件
  266. const uploadRes = await uploadFileNew({
  267. module: 'fm',
  268. multiPartFile: item.pdfFile
  269. });
  270. // 获取文件地址
  271. const fileUrl = uploadRes.data;
  272. // 更新文档地址
  273. await fileUpdateAPI({
  274. stampStoragePath: [fileUrl],
  275. id: item.id
  276. });
  277. // 处理签章使用记录
  278. if (item.droppedImages && item.droppedImages.length) {
  279. item.droppedImages.forEach((dropItem) => {
  280. if (dropItem.imgId) {
  281. usageRecordAdd({
  282. sealId: dropItem.imgId,
  283. sealName: dropItem.name,
  284. version: dropItem.version,
  285. documentCode: item.code,
  286. documentName: item.name,
  287. usageObjectId: item.id,
  288. usageObjectName: item.name,
  289. usageDeptName: this.$store.state.user.info.groupName,
  290. usageDeptId: this.$store.state.user.info.groupId,
  291. userName: this.$store.state.user.info.name,
  292. userId: this.$store.state.user.info.userId,
  293. useTime: new Date()
  294. });
  295. }
  296. });
  297. }
  298. });
  299. await Promise.all(uploadPromises);
  300. return 2;
  301. },
  302. async init() {
  303. const data = await sendGetById(this.businessId);
  304. this.form = data;
  305. this.fileList = data.fileList.map((item) => {
  306. item['droppedImages'] = '';
  307. item['pdfFile'] = '';
  308. return item;
  309. });
  310. this.$nextTick(() => {
  311. this.$refs.powerRef &&
  312. this.$refs.powerRef.setTableList(data.userAuthority);
  313. });
  314. },
  315. async browseOpen(row, type) {
  316. if (type == 1) {
  317. let data = await getById(row.id);
  318. this.$refs.sealManagementRef.open({
  319. ...data,
  320. droppedImages: row.droppedImages
  321. });
  322. } else {
  323. this.$refs.browseRef.open(await getById(row.id));
  324. }
  325. }
  326. }
  327. };
  328. </script>
  329. <style scoped lang="scss"></style>