main.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <ele-modal
  3. width="60%"
  4. :visible.sync="showEditFlag"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form"
  7. append-to-body
  8. ref="Emodal"
  9. :maxable="true"
  10. :resizable="true"
  11. >
  12. <!-- 数据表格 -->
  13. <ele-pro-table
  14. ref="table"
  15. :columns="columns"
  16. :datasource="tableList"
  17. tool-class="ele-toolbar-form"
  18. :needPage="false"
  19. row-key="id"
  20. :cache-key="cacheKeyUrl"
  21. >
  22. <template v-slot:toolbar v-if="type != 'view'">
  23. <el-button type="primary" @click="fileEditOpen">本地上传</el-button>
  24. <el-button type="primary" @click="fileShow = true">
  25. 关联文档库
  26. </el-button>
  27. </template>
  28. <!-- 操作列 -->
  29. <template v-slot:action="{ row }">
  30. <el-link
  31. type="primary"
  32. :underline="false"
  33. icon="el-icon-edit"
  34. @click="browseOpen(row)"
  35. >
  36. 浏览
  37. </el-link>
  38. <el-popconfirm
  39. v-if="type != 'view'"
  40. class="ele-action"
  41. title="确定要删除吗?"
  42. @confirm="remove(row)"
  43. >
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">
  46. 删除
  47. </el-link>
  48. </template>
  49. </el-popconfirm>
  50. </template>
  51. </ele-pro-table>
  52. <template v-slot:footer>
  53. <el-button @click="showEditFlag = false">取消</el-button>
  54. <el-button type="primary" @click="addFile" v-if="type != 'view'">
  55. 确认
  56. </el-button>
  57. </template>
  58. <fileEdit ref="fileEditRef" @done="done"></fileEdit>
  59. <ele-modal
  60. width="80%"
  61. :visible.sync="fileShow"
  62. :close-on-click-modal="false"
  63. custom-class="ele-dialog-form"
  64. append-to-body
  65. :maxable="true"
  66. :resizable="true"
  67. >
  68. <doc_template
  69. :disabledTableList="tableList"
  70. ref="doc_templateRef"
  71. ></doc_template>
  72. <template v-slot:footer>
  73. <el-button @click="fileShow = false">取消</el-button>
  74. <el-button type="primary" @click="addTemplate"> 确认 </el-button>
  75. </template>
  76. </ele-modal>
  77. <browse ref="browseRef"></browse>
  78. </ele-modal>
  79. </template>
  80. <script>
  81. import doc_template from './doc_template.vue';
  82. import fileEdit from './file-edit.vue';
  83. import browse from './browse.vue';
  84. import { queryIds } from './api';
  85. import { setFileUrl } from './util.js';
  86. import tabMixins from '@/mixins/tableColumnsMixin';
  87. export default {
  88. mixins: [tabMixins],
  89. components: { doc_template, fileEdit, browse },
  90. data() {
  91. return {
  92. fileId: [],
  93. fileShow: false,
  94. showEditFlag: false,
  95. tableList: [],
  96. type: 'add',
  97. cacheKeyUrl: 'eam-addDoc-main',
  98. tabMixinsInit: false,
  99. columns: [
  100. {
  101. label: '编码',
  102. prop: 'code',
  103. width: 180,
  104. align: 'center',
  105. showOverflowTooltip: true
  106. },
  107. {
  108. prop: 'name',
  109. label: '文档名称',
  110. align: 'center',
  111. slot: 'name',
  112. showOverflowTooltip: true,
  113. minWidth: 200
  114. },
  115. {
  116. prop: 'storagePath',
  117. label: '文件名称',
  118. align: 'center',
  119. showOverflowTooltip: true,
  120. minWidth: 200,
  121. formatter: (_row, _column, cellValue) => {
  122. return cellValue && cellValue[0]?.name;
  123. }
  124. },
  125. {
  126. prop: 'version',
  127. label: '版本',
  128. align: 'center',
  129. showOverflowTooltip: true,
  130. minWidth: 100
  131. },
  132. {
  133. prop: 'createUserName',
  134. label: '创建人',
  135. align: 'center',
  136. showOverflowTooltip: true,
  137. minWidth: 100
  138. },
  139. {
  140. prop: 'createTime',
  141. label: '创建时间',
  142. align: 'center',
  143. showOverflowTooltip: true,
  144. minWidth: 160
  145. },
  146. {
  147. prop: 'sizeUnit',
  148. label: '文档大小',
  149. align: 'center',
  150. showOverflowTooltip: true,
  151. minWidth: 100
  152. },
  153. {
  154. columnKey: 'action',
  155. label: '操作',
  156. width: 200,
  157. align: 'center',
  158. resizable: false,
  159. slot: 'action',
  160. showOverflowTooltip: true
  161. }
  162. ]
  163. };
  164. },
  165. created() {},
  166. methods: {
  167. open(fileId, type) {
  168. //查看详情:view 新增:add
  169. this.showEditFlag = true;
  170. this.fileId = fileId || [];
  171. if (type) {
  172. this.type = type;
  173. }
  174. this.init();
  175. },
  176. fileEditOpen() {
  177. this.$refs.fileEditRef.open();
  178. },
  179. remove(row) {
  180. this.tableList = this.tableList.filter((item) => item.code != row.code);
  181. this.fileId = this.tableList.map((item) => item.id);
  182. },
  183. async init() {
  184. if (this.fileId.length > 0) {
  185. this.tableList = await queryIds({ ids: "'" + this.fileId + "'" });
  186. } else {
  187. this.tableList = [];
  188. }
  189. },
  190. done(id) {
  191. this.fileId.push(...id);
  192. this.init();
  193. },
  194. browseOpen(row) {
  195. window.open(setFileUrl(row));
  196. },
  197. addFile() {
  198. this.$emit(
  199. 'success',
  200. this.tableList.map((item) => item.id)
  201. );
  202. this.showEditFlag = false;
  203. },
  204. addTemplate() {
  205. let list = this.$refs.doc_templateRef.getTableList();
  206. this.fileShow = false;
  207. if (list.length == 0) {
  208. this.$message.error('请选择一条数据');
  209. return;
  210. }
  211. this.tableList.push(...list);
  212. }
  213. }
  214. };
  215. </script>