xm-annual-report-form.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <span>
  3. <sd-webflow ref="flow" :removed-tabs="['sdRelatedDoc']" :class="$style.materialListForm">
  4. <template v-slot:form="{ model, fields }">
  5. <div v-show="loading" :class="$style.loadingDiv">
  6. <a-spin :spinning="true" tip="创建数据中..." />
  7. </div>
  8. <table>
  9. <tr>
  10. <!-- <sd-form-item-td name="fileTitle" :colspan="10" /> -->
  11. <sd-form-item-td name="fileTitle" :colspan="10">
  12. <template>
  13. <a-input v-if="!isShow" v-model="model.fileTitle"></a-input>
  14. <span v-else read-only>{{ model.fileTitle }}</span>
  15. </template>
  16. </sd-form-item-td>
  17. <sd-form-item-td name="reportYear" :colspan="10">
  18. <template>
  19. <a-date-picker
  20. v-if="!isShow"
  21. v-model="model.reportYear"
  22. mode="year"
  23. picker="YYYY"
  24. format="YYYY"
  25. :allow-clear="false"
  26. placeholder="选择年度"
  27. :input-read-only="true"
  28. :open="endOpen"
  29. :value="year"
  30. @panelChange="yearChange"
  31. @openChange="handleEndOpenChange"
  32. ></a-date-picker>
  33. <span v-else read-only>{{ model.reportYear }}</span>
  34. </template>
  35. </sd-form-item-td>
  36. </tr>
  37. <tr>
  38. <sd-form-item-td name="auditedUnit" :colspan="10" />
  39. <!-- <sd-form-item-td name="lastTime" :colspan="10"> </sd-form-item-td> -->
  40. <sd-form-item-td name="lastTime" :colspan="10">
  41. <template>
  42. <a-date-picker v-if="!isShow" v-model="model.lastTime"></a-date-picker>
  43. <span v-else read-only>{{ model.lastTime | sdDateFormat('YYYY-MM-DD') }}</span>
  44. </template>
  45. </sd-form-item-td>
  46. </tr>
  47. <tr>
  48. <sd-form-item-td name="attachment" :colspan="10"> </sd-form-item-td>
  49. </tr>
  50. <tr>
  51. <sd-form-item-td name="description" :colspan="21">
  52. <a-textarea v-model="model.description" :rows="3" />
  53. </sd-form-item-td>
  54. </tr>
  55. <tr>
  56. <!-- 编辑人员 -->
  57. <sd-form-item-td name="creatorName" :colspan="10" />
  58. <!-- 编辑日期 -->
  59. <sd-form-item-td name="creationTime" :colspan="10" />
  60. </tr>
  61. </table>
  62. <table>
  63. <tr
  64. ><td :colspan="4">
  65. <sd-form-item
  66. name="spicAnnualReportItemEntities"
  67. :label="null"
  68. :input-td-attrs="{ class: 'materialEntities' }"
  69. >
  70. <template v-slot:read-and-edit="{ editable }">
  71. <audit-advanced-group
  72. :expand="expand"
  73. :expand-str="'expand'"
  74. :group-label="'资料清单'"
  75. @changedClick="changedClick"
  76. >
  77. <template>
  78. <div v-show="expand && editable" :class="$style.btnmubandiv">
  79. <a-button type="link" :class="$style.btnmuban" @click="showImportTable"
  80. ><a-icon type="check-circle" :theme="'filled'" />
  81. 用模板创建
  82. </a-button>
  83. </div>
  84. <sd-child-table
  85. ref="childTable"
  86. v-model="model.spicAnnualReportItemEntities"
  87. :class="$style.projecttable"
  88. label=""
  89. :read-only="!editable"
  90. :sequence-column="true"
  91. :fields="Array.from(fields.spicAnnualReportItemEntities.attr.dync)"
  92. :columns="childColumns"
  93. @change="changeCTable"
  94. >
  95. <!-- input-form 表示这部分是子表组件的form插槽 -->
  96. <template v-slot:form="{ model, fields }">
  97. <table :class="$style.xmTable">
  98. <tr>
  99. <sd-form-item-td name="dataName" :colspan="3" />
  100. </tr>
  101. <tr>
  102. <sd-form-item-td name="dataDesc" :colspan="3">
  103. <a-textarea v-model="model.dataDesc" :rows="3" />
  104. </sd-form-item-td>
  105. </tr>
  106. <tr>
  107. <!-- 资料类型 -->
  108. <sd-form-item-td name="dataType" component="a-select" :colspan="3" />
  109. </tr>
  110. <tr>
  111. <!-- 附件 -->
  112. <sd-form-item-td name="attachment">
  113. <template v-slot:read-and-edit="{ editable }">
  114. <sd-attachment
  115. v-model="model.attachment"
  116. :read-only="editable ? false : true"
  117. :group-id="JSON.parse(fields.attachment.value).value"
  118. />
  119. </template>
  120. </sd-form-item-td>
  121. </tr>
  122. </table>
  123. </template>
  124. <template v-slot:attachment="{ field, text, record }">
  125. <div @click="attClick">
  126. <sd-attachment
  127. :key="key"
  128. :read-only="editable ? false : true"
  129. :group-id="JSON.parse(text).value ? JSON.parse(text).value : text"
  130. />
  131. </div>
  132. </template>
  133. </sd-child-table>
  134. </template>
  135. </audit-advanced-group>
  136. </template>
  137. </sd-form-item>
  138. </td>
  139. </tr>
  140. </table>
  141. </template>
  142. </sd-webflow>
  143. <!-- 选择导入模板 -->
  144. <a-modal
  145. :visible="visible"
  146. title="选择模板"
  147. width="50%"
  148. :destroy-on-close="true"
  149. @ok="handleOk"
  150. @cancel="handleCancel"
  151. >
  152. <sd-data-table-ex
  153. ref="importTable"
  154. check-type="radio"
  155. :filter-expressions="expressions"
  156. :columns="columns2"
  157. form-id="iamTemplate"
  158. page-id="audit/template/iamTemplate"
  159. :search-fields="['templateName', 'templateType', 'isDefault']"
  160. show-selection
  161. >
  162. </sd-data-table-ex>
  163. </a-modal>
  164. </span>
  165. </template>
  166. <script>
  167. import components from './_import-components/xm-annual-report-form-import'
  168. import { Message } from 'ant-design-vue'
  169. import TableColumnTypes from '@/common/services/table-column-types'
  170. import xmSpicAnnualReportService from './xm-spic-annual-report-service'
  171. import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
  172. import auditAdvancedGroup from '@product/iam/components/audit-advanced-group.vue'
  173. export default {
  174. name: 'XmAnnualReportForm',
  175. metaInfo() {
  176. return {
  177. title: '年度报告库',
  178. }
  179. },
  180. components: { ...components, auditAdvancedGroup },
  181. mixins: [auditAdvancedGroupMixins],
  182. data() {
  183. return {
  184. loading: false,
  185. projectId: null,
  186. visible: false,
  187. expand: true,
  188. isShow: false,
  189. key: 1,
  190. endOpen: false,
  191. childFields: [],
  192. expressions: [
  193. {
  194. dataType: 'str',
  195. name: 'templateType',
  196. op: 'like',
  197. stringValue: '%4%',
  198. },
  199. ],
  200. childColumns: [
  201. {
  202. title: '序号',
  203. dataIndex: 'sortNum',
  204. customRender: (text, record, index) => `${index + 1}`,
  205. },
  206. {
  207. title: '资料名称',
  208. width: '350px',
  209. dataIndex: 'dataName',
  210. },
  211. {
  212. title: '资料描述',
  213. width: '350px',
  214. dataIndex: 'dataDesc',
  215. },
  216. {
  217. title: '资料类型',
  218. width: '100px',
  219. dataIndex: 'dataType',
  220. },
  221. {
  222. title: '附件',
  223. width: '200px',
  224. dataIndex: 'attachment',
  225. },
  226. ],
  227. columns2: [
  228. {
  229. title: '序号',
  230. dataIndex: 'sortNumber',
  231. width: '70px',
  232. customRender: (text, record, index) => `${index + 1}`,
  233. },
  234. {
  235. title: '模板名称',
  236. dataIndex: 'templateName',
  237. scopedSlots: { customRender: 'islink' },
  238. },
  239. {
  240. title: '模板类型',
  241. dataIndex: 'templateType',
  242. },
  243. {
  244. title: '编制日期',
  245. dataIndex: 'authTime',
  246. sdRender: TableColumnTypes.date,
  247. sorter: true,
  248. defaultSortOrder: 'desc',
  249. },
  250. {
  251. title: '附件',
  252. dataIndex: 'attachment',
  253. sdHidden: true,
  254. },
  255. ],
  256. }
  257. },
  258. mounted() {
  259. debugger
  260. const autoCreate = this.$refs.flow.getFieldValue('autoCreate')
  261. if (autoCreate === '1') {
  262. this.isShow = true
  263. }
  264. // const fileTitle = this.$refs.flow.getFieldValue('fileTitle')
  265. // this.$refs.flow.setFieldValue('title', fileTitle + '的年度报告')
  266. },
  267. methods: {
  268. showImportTable() {
  269. this.visible = !this.visible
  270. },
  271. yearChange(value) {
  272. this.year = value
  273. this.$refs.flow.setFieldValue('reportYear', value.format('YYYY'))
  274. this.$refs.flow.validateField('reportYear').then((res) => {
  275. console.log(res)
  276. })
  277. if (document.getElementsByClassName('ant-calendar-picker-container').length > 0) {
  278. document.getElementsByClassName('ant-calendar-picker-container')[0].style.display = 'none'
  279. }
  280. },
  281. handleEndOpenChange(open) {
  282. this.endOpen = open
  283. },
  284. // 弹出窗确认
  285. handleOk() {
  286. this.loading = true
  287. this.showImportTable()
  288. // 获取别选择的行信息
  289. const selectInfo = this.$refs.importTable.getSelectedRows()
  290. xmSpicAnnualReportService.importAnnualPeportInfo(selectInfo[0].attachment).then((res) => {
  291. Message.success('模板创建成功')
  292. const data = this.$refs.flow.getFieldValue('spicAnnualReportItemEntities') || []
  293. const tableData = data.concat(res.data)
  294. tableData.forEach((item, index) => {
  295. if (!item.id) {
  296. item.id = 'fakeId' + index + 1
  297. }
  298. })
  299. this.$refs.flow.setFieldValue('spicAnnualReportItemEntities', tableData)
  300. this.loading = false
  301. })
  302. },
  303. // 附件列点击,停止默认事件
  304. attClick() {
  305. event.stopPropagation()
  306. },
  307. // 弹出窗取消
  308. handleCancel() {
  309. this.showImportTable()
  310. },
  311. changeCTable() {
  312. this.key++
  313. },
  314. },
  315. }
  316. </script>
  317. <style module lang="scss">
  318. @import '@/webflow/sd-flow-form.scss';
  319. .xm-table {
  320. :global(td.ant-form-item-label) {
  321. width: 15%;
  322. }
  323. }
  324. .btnmubandiv {
  325. position: relative;
  326. .btnmuban {
  327. position: absolute;
  328. top: 0;
  329. right: 190px;
  330. z-index: 100;
  331. }
  332. }
  333. :global(.ant-upload) {
  334. background: transparent !important;
  335. border: none !important;
  336. }
  337. // :global(.ant-upload-text) {
  338. // display: none !important;
  339. // }
  340. :global(.ant-upload-drag-icon) {
  341. margin-bottom: 0 !important;
  342. :global(.anticon) {
  343. font-size: 26px !important;
  344. }
  345. }
  346. .material-list-form {
  347. :global(.child-table-title) {
  348. display: none;
  349. }
  350. }
  351. .child-td {
  352. :global(.groupstyle_audit-advanced-group_product) {
  353. margin-left: 4px;
  354. }
  355. }
  356. .loading-div {
  357. position: absolute;
  358. z-index: 101;
  359. display: flex;
  360. flex-direction: column;
  361. justify-content: center;
  362. width: 100%;
  363. height: 100%;
  364. background: rgb(255 255 255 / 70%);
  365. }
  366. </style>