main.vue 5.4 KB

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