xm-annual-report-puiblish-form.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <span>
  3. <audit-form-top-banner
  4. :handel-save-form="saveForm"
  5. :handel-publish="handelPublish"
  6. :form-data="mode"
  7. :model="searchForm"
  8. :hiden-or-show="hidenOR0Show"
  9. @handelSaveForm="saveForm"
  10. @handelPublish="handelPublish"
  11. >
  12. <sd-detail-form
  13. ref="docform"
  14. page-id="audit/spicannualreportpublish/spicAnnualReportPublish"
  15. :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
  16. :class="$style.form"
  17. :read-only="readOnly"
  18. @close="close(true)"
  19. @saved="saved"
  20. @sdFormReady="sdFormReady"
  21. >
  22. <template v-slot="{ model, fields }">
  23. <div v-show="loading" :class="$style.loadingDiv">
  24. <a-spin :spinning="true" tip="创建数据中..." />
  25. </div>
  26. <!-- <table :class="$style.table">
  27. <colgroup>
  28. <col :class="$style.label" />
  29. <col :class="$style.input" />
  30. <col :class="$style.label" />
  31. <col :class="$style.input" />
  32. </colgroup> -->
  33. <table>
  34. <tr>
  35. <sd-form-item-td name="fileTitle" :colspan="10" />
  36. <sd-form-item-td name="reportYear" :colspan="10">
  37. <a-date-picker
  38. v-model="model.reportYear"
  39. mode="year"
  40. picker="YYYY"
  41. format="YYYY"
  42. :allow-clear="false"
  43. placeholder="选择年度"
  44. :input-read-only="true"
  45. :open="endOpen"
  46. :value="year"
  47. @panelChange="yearChange"
  48. @openChange="handleEndOpenChange"
  49. ></a-date-picker>
  50. </sd-form-item-td>
  51. </tr>
  52. <tr>
  53. <sd-form-item-td name="auditedUnit" :colspan="10" />
  54. <sd-form-item-td name="lastTime" :colspan="10" />
  55. </tr>
  56. <tr>
  57. <sd-form-item-td name="description" :colspan="21">
  58. <a-textarea v-model="model.description" :rows="3" />
  59. </sd-form-item-td>
  60. </tr>
  61. <tr>
  62. <!-- 文档附件 -->
  63. <sd-form-item-td name="attachment" :colspan="21" />
  64. </tr>
  65. <tr>
  66. <sd-form-item-td name="viewPeoples" :colspan="21" />
  67. </tr>
  68. <tr>
  69. <sd-form-item-td name="creatorName" :colspan="10" />
  70. <sd-form-item-td name="creationTime" :colspan="10" />
  71. </tr>
  72. <tr>
  73. <sd-form-item-td name="uuid" :colspan="10" hidden="true" />
  74. </tr>
  75. </table>
  76. <table>
  77. <tr
  78. ><td :colspan="4">
  79. <sd-form-item
  80. name="spicAnnualReportPublishItemEntities"
  81. :label="null"
  82. :input-td-attrs="{ class: 'annualReportPublishItemEntities' }"
  83. >
  84. <template v-slot:read-and-edit="{ editable }">
  85. <audit-advanced-group
  86. :expand="moneyExpand"
  87. :expand-str="'moneyExpand'"
  88. :group-label="'年度报告'"
  89. @changedClick="changedClick"
  90. >
  91. <template>
  92. <div v-show="moneyExpand && editable" :class="$style.btnmubandiv">
  93. <a-button type="link" :class="$style.btnmuban" @click="showImportTable"
  94. ><a-icon type="check-circle" :theme="'filled'" />
  95. 用模板创建
  96. </a-button>
  97. </div>
  98. <!-- :read-only="!editable" -->
  99. <sd-child-table
  100. ref="childTable"
  101. v-model="model.spicAnnualReportPublishItemEntities"
  102. :class="$style.deptPlanChild"
  103. label=""
  104. :read-only="!childEdit"
  105. :sequence-column="true"
  106. :fields="Array.from(fields.spicAnnualReportPublishItemEntities.attr.dync)"
  107. :columns="childColumns"
  108. @change="changeCTable"
  109. >
  110. <!-- input-form 表示这部分是子表组件的form插槽 -->
  111. <template v-slot:form="{ model, fields }">
  112. <table :class="$style.xmTable">
  113. <tr>
  114. <sd-form-item-td name="dataName" :colspan="3" />
  115. </tr>
  116. <tr>
  117. <sd-form-item-td name="dataDesc" :colspan="3">
  118. <a-textarea v-model="model.dataDesc" :rows="3" />
  119. </sd-form-item-td>
  120. </tr>
  121. <tr>
  122. <!-- 资料类型 -->
  123. <sd-form-item-td
  124. name="dataType"
  125. component="a-select"
  126. :colspan="3"
  127. />
  128. </tr>
  129. <tr>
  130. <sd-form-item-td name="attachment" :colspan="3" />
  131. </tr>
  132. </table>
  133. </template>
  134. </sd-child-table>
  135. </template>
  136. </audit-advanced-group>
  137. </template>
  138. </sd-form-item>
  139. </td>
  140. </tr>
  141. </table>
  142. </template>
  143. </sd-detail-form>
  144. </audit-form-top-banner>
  145. <!-- 选择导入模板 -->
  146. <a-modal
  147. :visible="visible"
  148. title="选择模板"
  149. width="50%"
  150. :destroy-on-close="true"
  151. @ok="handleOk"
  152. @cancel="handleCancel"
  153. >
  154. <sd-data-table-ex
  155. ref="importTable"
  156. check-type="radio"
  157. :filter-expressions="expressions"
  158. :columns="columns2"
  159. form-id="iamTemplate"
  160. page-id="audit/template/iamTemplate"
  161. :search-fields="['templateName', 'templateType', 'isDefault']"
  162. show-selection
  163. >
  164. </sd-data-table-ex>
  165. </a-modal>
  166. </span>
  167. </template>
  168. <script>
  169. import { Message, Modal } from 'ant-design-vue'
  170. import axios from '@/common/services/axios-instance'
  171. import { getUserInfo } from '@/common/store-mixin'
  172. import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
  173. import auditAdvancedGroup from '@product/iam/components/audit-advanced-group.vue'
  174. import TableColumnTypes from '@/common/services/table-column-types'
  175. import xmSpicAnnualReportService from './xm-spic-annual-report-service'
  176. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  177. import auditFormTopBanner from '@product/iam/components/audit-form-top-banner'
  178. import components from './_import-components/xm-annual-report-puiblish-form-import'
  179. export default {
  180. name: 'XmAnnualReportPuiblishForm',
  181. metaInfo: {
  182. title: '年报资料下发',
  183. },
  184. components: { ...components, auditFormTopBanner, auditAdvancedGroup },
  185. mixins: [auditAdvancedGroupMixins],
  186. data() {
  187. return {
  188. columns2: [
  189. {
  190. title: '序号',
  191. dataIndex: 'sortNumber',
  192. width: '70px',
  193. customRender: (text, record, index) => `${index + 1}`,
  194. },
  195. {
  196. title: '模板名称',
  197. dataIndex: 'templateName',
  198. scopedSlots: { customRender: 'islink' },
  199. },
  200. {
  201. title: '模板类型',
  202. dataIndex: 'templateType',
  203. },
  204. {
  205. title: '编制日期',
  206. dataIndex: 'authTime',
  207. sdRender: TableColumnTypes.date,
  208. sorter: true,
  209. defaultSortOrder: 'desc',
  210. },
  211. {
  212. title: '附件',
  213. dataIndex: 'attachment',
  214. sdHidden: true,
  215. },
  216. ],
  217. expressions: [
  218. {
  219. dataType: 'str',
  220. name: 'templateType',
  221. op: 'like',
  222. stringValue: '%4%',
  223. },
  224. ],
  225. childColumns: [
  226. {
  227. title: '序号',
  228. dataIndex: 'sortNum',
  229. customRender: (text, record, index) => `${index + 1}`,
  230. },
  231. {
  232. title: '资料名称',
  233. dataIndex: 'dataName',
  234. },
  235. {
  236. title: '资料描述',
  237. dataIndex: 'dataDesc',
  238. },
  239. {
  240. title: '资料类型',
  241. dataIndex: 'dataType',
  242. },
  243. // {
  244. // title: '附件',
  245. // dataIndex: 'attachment',
  246. // },
  247. ],
  248. loading: false,
  249. projectId: null,
  250. visible: false,
  251. year: null,
  252. endOpen: false,
  253. moneyExpand: true,
  254. mode: null,
  255. hidenOR0Show: true,
  256. readOnly: false,
  257. childEdit: true,
  258. publish: 0, // 为1 时是发布
  259. hasOperatePermissions: true,
  260. showYearPicker: false,
  261. searchForm: {},
  262. }
  263. },
  264. methods: {
  265. // 页面加载完成后
  266. sdFormReady() {
  267. debugger
  268. const ini = setInterval(() => {
  269. if (
  270. this.$refs.docform &&
  271. (this.$refs.docform.$refs.form || this.$refs.docform.$refs.sdForm)
  272. ) {
  273. clearInterval(ini)
  274. this.mode = this.$refs.docform.formData.mode
  275. if (this.$refs.docform.formData.pageFormData.beanId) {
  276. const status = this.$refs.docform.getFieldValue('status')
  277. if (status === '已发布') {
  278. this.hidenOR0Show = false
  279. this.readOnly = true
  280. this.moneyExpand = false
  281. this.childEdit = false
  282. this.mode = 'VIEW'
  283. } else {
  284. const creatorAccount = this.$refs.docform.getFieldValue('creatorAccount')
  285. if (creatorAccount !== getUserInfo().account) {
  286. this.hidenOR0Show = false
  287. this.readOnly = true
  288. this.childEdit = false
  289. this.moneyExpand = false
  290. this.mode = 'VIEW'
  291. }
  292. }
  293. }
  294. }
  295. }, 100)
  296. // if (!this.hasOperatePermissions) {
  297. // this.$refs.docform.formData.mode = 'VIEW'
  298. // }
  299. // this.mode = this.$refs.docform.formData.mode
  300. // const docStatus = this.$refs.docform.getFieldValue('status')
  301. // if (docStatus === '已发布') {
  302. // this.hidenOR0Show = false
  303. // }
  304. axios({
  305. url: 'api/xcoa-mobile/v1/spicannualreportpublish/createSpicAnnualUuid',
  306. method: 'post',
  307. }).then((res) => {
  308. const uuid = res.data
  309. this.$refs.docform.setFieldValue('uuid', uuid)
  310. })
  311. },
  312. showImportTable() {
  313. this.visible = !this.visible
  314. },
  315. yearChange(value) {
  316. this.year = value
  317. this.$refs.docform.setFieldValue('reportYear', value.format('YYYY'))
  318. this.$refs.docform.validateField('reportYear').then((res) => {
  319. console.log(res)
  320. })
  321. if (document.getElementsByClassName('ant-calendar-picker-container').length > 0) {
  322. document.getElementsByClassName('ant-calendar-picker-container')[0].style.display = 'none'
  323. }
  324. },
  325. handleEndOpenChange(open) {
  326. this.endOpen = open
  327. },
  328. // 保存
  329. saveForm() {
  330. this.$refs.docform.saveBtnClick()
  331. this.$refs.docform.setFieldValue('status', '起草中')
  332. },
  333. handelPublish() {
  334. this.$refs.docform.validateFields().then(() => {
  335. Modal.confirm({
  336. title: '提示',
  337. content: '请确认是否发布当前数据',
  338. onOk: () => {
  339. // 发布,保存
  340. this.$refs.docform.setFieldValue('status', '已发布')
  341. this.publish = 1
  342. this.$refs.docform.save().then((res) => {
  343. const id = this.$refs.docform.getFieldValue('id')
  344. const uuid = this.$refs.docform.getFieldValue('uuid')
  345. axios({
  346. url: 'api/xcoa-mobile/v1/spicannualreportpublish/createSpicAnnualReportFlow',
  347. method: 'post',
  348. data: { uuid: uuid },
  349. })
  350. .then((res) => {
  351. if (res.data.isRequestSuccess === 'false') {
  352. Message.error('年度资料下发失败,请联系系统管理员')
  353. } else {
  354. Message.success('发布成功', 1).then((res) => {
  355. this.close(true)
  356. })
  357. }
  358. })
  359. .catch(() => {
  360. Message.error('服务异常')
  361. })
  362. })
  363. },
  364. onCancel: () => {},
  365. })
  366. })
  367. },
  368. saved() {
  369. if (this.publish === 1) {
  370. Message.success('发布成功', 1).then((res) => {
  371. this.close(true)
  372. })
  373. } else {
  374. Message.success('保存成功', 1).then((res) => {
  375. this.close(true)
  376. })
  377. }
  378. },
  379. close(flag) {
  380. crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
  381. window.close()
  382. },
  383. // 弹出窗确认
  384. handleOk() {
  385. this.loading = true
  386. this.showImportTable()
  387. // 获取别选择的行信息
  388. const selectInfo = this.$refs.importTable.getSelectedRows()
  389. xmSpicAnnualReportService
  390. .importAnnualPeportPublishInfo(selectInfo[0].attachment)
  391. .then((res) => {
  392. Message.success('模板创建成功')
  393. const data = this.$refs.docform.getFieldValue('spicAnnualReportPublishItemEntities') || []
  394. const tableData = data.concat(res.data)
  395. tableData.forEach((item, index) => {
  396. if (!item.id) {
  397. item.id = 'fakeId' + index + 1
  398. }
  399. })
  400. this.$refs.docform.setFieldValue('spicAnnualReportPublishItemEntities', tableData)
  401. this.loading = false
  402. })
  403. },
  404. // 弹出窗取消
  405. handleCancel() {
  406. this.showImportTable()
  407. },
  408. changeCTable() {
  409. this.key++
  410. },
  411. },
  412. }
  413. </script>
  414. <style module lang="scss">
  415. @import '@/webflow/sd-flow-form.scss';
  416. .xm-table {
  417. :global(td.ant-form-item-label) {
  418. width: 15%;
  419. }
  420. }
  421. .btnmubandiv {
  422. position: relative;
  423. .btnmuban {
  424. position: absolute;
  425. top: 0;
  426. right: 190px;
  427. z-index: 100;
  428. }
  429. }
  430. .btnselect {
  431. position: relative;
  432. float: right;
  433. .batchselect {
  434. top: 4px;
  435. z-index: 100;
  436. margin-right: 200px;
  437. }
  438. }
  439. .form {
  440. :global .iamauditfindform > td.ant-form-item-label > label {
  441. white-space: break-spaces !important;
  442. }
  443. }
  444. .loading-div {
  445. position: absolute;
  446. z-index: 101;
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: center;
  450. width: 100%;
  451. height: 100%;
  452. background: rgb(255 255 255 / 70%);
  453. }
  454. </style>