main.vue 5.5 KB

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