sd-print-maintain.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <a-card>
  3. <component
  4. :is="computedAppId ? SdDataTableEx : SdDataTableSys"
  5. ref="printTable"
  6. ex
  7. form-id="oaDocPrintTemplate"
  8. page-id="base/print/oaDocPrintTemplate"
  9. :filter-expressions="expressions"
  10. :columns="columns"
  11. show-selection
  12. :actions="actions"
  13. :search-fields="['templateName']"
  14. >
  15. <template v-slot:form="{ model, fields }">
  16. <sd-form-item
  17. v-if="computedAppId"
  18. name="appId"
  19. hidden
  20. :input-props="{ defaultValue: computedAppId }"
  21. />
  22. <sd-form-item name="templateName"></sd-form-item>
  23. <sd-form-item name="attachment">
  24. <template v-slot:read-and-edit>
  25. <sd-attachment
  26. v-model="model.attachment"
  27. :max="1"
  28. :group-id="JSON.parse(fields.attachment.value).value"
  29. accept=".docx"
  30. />
  31. </template>
  32. </sd-form-item>
  33. <sd-form-item name="status"></sd-form-item>
  34. </template>
  35. </component>
  36. <!-- 批量导入 -->
  37. <a-modal
  38. v-model="isBatchImport"
  39. title="打印模版批量导入"
  40. destroy-on-close
  41. v-bind="{ width: 800 }"
  42. :mask-closable="false"
  43. @ok="bacthImport"
  44. @cancel="isBatchImport = false"
  45. >
  46. <a-form :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
  47. <a-form-item label="模板文件" :required="true">
  48. <sd-attachment :group-id="groupId" accept=".docx" />
  49. </a-form-item>
  50. </a-form>
  51. </a-modal>
  52. </a-card>
  53. </template>
  54. <script>
  55. import { Message } from 'ant-design-vue'
  56. import asyncComponent from '@/common/services/async-component'
  57. import TableColumnTypes from '../common/services/table-column-types'
  58. import TableActionTypes from '../common/services/table-action-types'
  59. import WorkbenchService from './workbench-service'
  60. import components from './_import-components/sd-print-maintain-import'
  61. const columns = [
  62. {
  63. title: '模板名称',
  64. dataIndex: 'templateName',
  65. sdClickable: true,
  66. width: '35%',
  67. },
  68. {
  69. title: '创建时间',
  70. dataIndex: 'creationTime',
  71. sdRender: TableColumnTypes.dateTime,
  72. sorter: true,
  73. width: '50%',
  74. },
  75. {
  76. title: '当前状态',
  77. dataIndex: 'status',
  78. sdRender: TableColumnTypes.ex.switch,
  79. },
  80. ]
  81. export default {
  82. name: 'SdPrintMaintain',
  83. metaInfo: {
  84. title: '打印配置维护管理',
  85. },
  86. components,
  87. props: {
  88. appId: {
  89. type: String,
  90. default: '',
  91. },
  92. },
  93. data() {
  94. return {
  95. showform: false,
  96. confirmLoading: false,
  97. columns,
  98. isBatchImport: false,
  99. actions: [
  100. {
  101. label: '批量导入',
  102. id: 'import',
  103. permission: null,
  104. callback: () => {
  105. WorkbenchService.getGroupCode().then((res) => {
  106. if (res.status === 200) {
  107. if (res.data) {
  108. this.groupId = res.data.toString()
  109. this.isBatchImport = true // 弹出导入面板
  110. } else {
  111. Message.error('获取groupId失败')
  112. }
  113. } else {
  114. Message.error(res.statusText)
  115. }
  116. })
  117. },
  118. },
  119. {
  120. label: '新建',
  121. id: 'new',
  122. type: TableActionTypes.ex.create,
  123. },
  124. {
  125. label: '删除',
  126. id: 'delete',
  127. type: TableActionTypes.ex.delete,
  128. },
  129. ],
  130. groupId: '', // 批量导入group附件组id
  131. routeAppId: '',
  132. }
  133. },
  134. computed: {
  135. computedAppId() {
  136. return this.appId || this.routeAppId
  137. },
  138. expressions() {
  139. const expressions = []
  140. if (this.computedAppId) {
  141. expressions.push({
  142. dataType: 'str',
  143. name: 'appId',
  144. op: 'eq',
  145. stringValue: this.computedAppId,
  146. })
  147. } else {
  148. expressions.push({
  149. dataType: 'str',
  150. name: 'appId',
  151. op: 'is_null',
  152. })
  153. }
  154. return expressions
  155. },
  156. },
  157. created() {
  158. this.SdDataTableEx = asyncComponent(() =>
  159. import(/* webpackChunkName: "sd-data-table" */ '@/common/components/sd-data-table-ex.vue')
  160. )
  161. this.SdDataTableSys = asyncComponent(() =>
  162. import(/* webpackChunkName: "sd-data-table" */ '@/common/components/sd-data-table-sys.vue')
  163. )
  164. this.routeAppId = this.$route.query.appId
  165. },
  166. methods: {
  167. bacthImport() {
  168. const belongedOrg = this.computedAppId ? null : this.$refs.printTable.getHierarchy()
  169. WorkbenchService.batchImport({
  170. groupId: this.groupId,
  171. appId: this.computedAppId,
  172. belongedOrgId: belongedOrg?.id,
  173. }).then((res) => {
  174. Message.success('上传成功')
  175. this.isBatchImport = false
  176. this.$refs.printTable.refresh()
  177. })
  178. },
  179. },
  180. }
  181. </script>
  182. <style module lang="scss">
  183. @use '@/common/design' as *;
  184. </style>