spic-engine-construce-base-form.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <sd-webflow ref="flow" :removed-tabs="['sdRelatedDoc']" :validate-form="validateForm">
  3. <template v-slot:form="{ model, fields }">
  4. <table
  5. ><tr v-show="false">
  6. <!-- 1.标题 -->
  7. <sd-form-item-td name="title" />
  8. <!-- 2.报送单位Name -->
  9. <sd-form-item-td name="submitUnitCode" />
  10. <sd-form-item-td name="submitUserCode" />
  11. </tr>
  12. <tr>
  13. <sd-form-item-td name="submitUnit"> </sd-form-item-td>
  14. <sd-form-item-td name="submitUser"> </sd-form-item-td>
  15. </tr>
  16. <tr>
  17. <sd-form-item-td name="submitMonth" :input-props="{ disabled: true }" />
  18. <sd-form-item-td name="submitDate" />
  19. </tr>
  20. <tr v-show="false">
  21. <sd-form-item-td name="submitUserName" />
  22. <sd-form-item-td name="submitUnitName" />
  23. </tr>
  24. <tr>
  25. <!-- 8.创建人 -->
  26. <sd-form-item-td name="creatorName" />
  27. <!-- 9.创建日期 -->
  28. <sd-form-item-td name="creationTime" />
  29. </tr>
  30. <tr v-show="false">
  31. <!-- id -->
  32. <sd-form-item-td name="id" />
  33. <sd-form-item-td name="randomId" :input-props="{ defaultValue: randomId }" />
  34. </tr>
  35. </table>
  36. <table>
  37. <tr :class="$style.lastTr">
  38. <td :colspan="8">
  39. <sd-form-item-td :label="null" name="spicEngineConstruceProjectList">
  40. <template v-slot:read-and-edit="{ editable }">
  41. <template>
  42. <div :class="$style.wrapper">
  43. <div v-show="projectExpand && editable" :class="$style.btnselect">
  44. <a-button type="link" :class="$style.batchselect" @click="getProject"
  45. ><a-icon type="check-circle" :theme="'filled'" />生成数据
  46. </a-button>
  47. <a-button type="link" :class="$style.batchselect" @click="remove"
  48. ><a-icon type="check-circle" :theme="'filled'" />删除
  49. </a-button>
  50. </div>
  51. </div>
  52. </template>
  53. <audit-advanced-group
  54. :expand="projectExpand"
  55. :expand-str="'projectExpand'"
  56. :group-label="'工程项目列表'"
  57. ><template>
  58. <xm-paper-child-table
  59. ref="tabaData"
  60. v-model="model.spicEngineConstruceProjectList"
  61. :disable-ad="true"
  62. :class="$style.deptPlanChild"
  63. name="spicEngineConstruceProjectList"
  64. label="信息填报"
  65. :fields="
  66. [
  67. {
  68. caption: '序号',
  69. name: 'sortNum',
  70. dataType: 'number',
  71. },
  72. ].concat(Array.from(fields.spicEngineConstruceProjectList.attr.dync))
  73. "
  74. :columns="childColumns"
  75. :captionvisiable="false"
  76. :flagpage="true"
  77. >
  78. <a
  79. slot="projectName"
  80. slot-scope="text, record"
  81. @click="linkProject(text.record, editable)"
  82. >{{ text.text }}</a
  83. >
  84. </xm-paper-child-table>
  85. </template>
  86. </audit-advanced-group>
  87. </template>
  88. </sd-form-item-td>
  89. </td>
  90. </tr>
  91. </table>
  92. </template>
  93. </sd-webflow>
  94. </template>
  95. <script>
  96. import { getUserInfo } from '@/common/store-mixin'
  97. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  98. import auditAdvancedGroup from '@product/iam/components/audit-advanced-group.vue'
  99. import xmPaperChildTable from '@product/iam/audit/work/operate/paper/table/xm-paper-child-table.vue'
  100. import components from './_import-components/spic-engine-construce-base-form-import'
  101. import axios from '@/common/services/axios-instance'
  102. import { Message, Modal } from 'ant-design-vue'
  103. import errorUtil from '@/common/services/error-util'
  104. import { data } from 'vue-echarts'
  105. export default {
  106. name: 'SpicEngineConstruceBaseForm',
  107. metaInfo: {
  108. title: '信息填报',
  109. },
  110. components: {
  111. ...components,
  112. auditAdvancedGroup,
  113. xmPaperChildTable,
  114. },
  115. data() {
  116. return {
  117. auditUnit: [],
  118. selectedRowKeys: [],
  119. projectExpand: true,
  120. randomId: '',
  121. childColumns: [
  122. {
  123. title: '序号',
  124. dataIndex: 'sortNum',
  125. width: '50px',
  126. customRender: (text, record, index) => `${index + 1}`,
  127. },
  128. {
  129. dataIndex: 'projectName',
  130. sorter: true,
  131. width: '15%',
  132. },
  133. { dataIndex: 'auditedUnitName', sorter: true, defaultSortOrder: 'ascend', width: '15%' },
  134. {
  135. dataIndex: 'auditType',
  136. sorter: false,
  137. customRender: (text, record, index) =>
  138. JSON.parse(text) === null ? '' : JSON.parse(text)[0].name,
  139. width: '15%',
  140. },
  141. { dataIndex: 'auditDecisionDate', sorter: true, width: '120px' },
  142. {
  143. dataIndex: 'submittedMonth',
  144. sorter: true,
  145. customRender: (text, record, index) =>
  146. JSON.parse(text) === null ? '' : JSON.parse(text)[0].name,
  147. width: '120px',
  148. },
  149. { dataIndex: 'submitUnitName', sorter: true, width: '120px' },
  150. {
  151. dataIndex: 'submittedQuarter',
  152. sorter: true,
  153. customRender: (text, record, index) =>
  154. JSON.parse(text) === null ? '' : JSON.parse(text)[0].name,
  155. width: '120px',
  156. },
  157. { dataIndex: 'id', sdHidden: true },
  158. { dataIndex: 'mainId', sdHidden: true },
  159. { dataIndex: 'investDecisionDate', sdHidden: true },
  160. { dataIndex: 'cumulativeInvestment', sdHidden: true },
  161. { dataIndex: 'commencementDate', sdHidden: true },
  162. { dataIndex: 'planedProductionDate', sdHidden: true },
  163. { dataIndex: 'projectCode', sdHidden: true },
  164. ],
  165. }
  166. },
  167. mounted() {
  168. this.initData()
  169. this.getRandomId()
  170. },
  171. methods: {
  172. getRandomId() {
  173. let randomNum = Math.random()
  174. while (randomNum === 0) {
  175. randomNum = Math.random()
  176. }
  177. const time = new Date().getTime()
  178. this.randomId = time + Math.ceil(randomNum * 1000000000)
  179. },
  180. linkProject(recordChild, editable) {
  181. // debugger
  182. const type = this.$route.params.type
  183. let isReadonly
  184. if (type === 'done-pages') {
  185. isReadonly = 'VIEW'
  186. } else {
  187. isReadonly = 'EDIT'
  188. }
  189. // let mainId = this.$refs.flow.getFieldValue('id')
  190. let mainId = recordChild.mainId
  191. if (mainId === undefined || mainId === '' || mainId === null) {
  192. mainId = this.randomId
  193. }
  194. let auditedUnitCode = recordChild.auditedUnitCode
  195. let id = recordChild.id
  196. if (recordChild.id === undefined || recordChild.id === null) {
  197. id = ''
  198. }
  199. if (recordChild.auditedUnitCode === undefined || recordChild.auditedUnitCode === null) {
  200. auditedUnitCode = ''
  201. }
  202. const url =
  203. '/spic-engine-construce-table?projectName=' +
  204. recordChild.projectName +
  205. '&auditedUnitName=' +
  206. recordChild.auditedUnitName +
  207. '&investDecisionDate=' +
  208. recordChild.investDecisionDate +
  209. '&cumulativeInvestment=' +
  210. recordChild.cumulativeInvestment +
  211. '&projectCode=' +
  212. recordChild.projectCode +
  213. '&commencementDate=' +
  214. recordChild.commencementDate +
  215. '&planedProductionDate=' +
  216. recordChild.planedProductionDate +
  217. '&mainId=' +
  218. mainId +
  219. '&id=' +
  220. id +
  221. '&auditedUnitCode=' +
  222. auditedUnitCode +
  223. '&isEdit=' +
  224. isReadonly // 编辑面要打开的路由地址
  225. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  226. if (refreshFlag) {
  227. setTimeout(this.getConstruceFind(mainId), 3000)
  228. }
  229. })
  230. },
  231. // saveproject(formdata) {
  232. // this.isSave = true
  233. // const selectedKeys = formdata.processFormData.processFormPropertyValues
  234. // selectedKeys.forEach((item) => {
  235. // if (item.name === 'paperCode') {
  236. // this.$refs.flow.setFieldValue('paperCode', item.value)
  237. // } else if (item.name === 'iamWorkPaperMaterialEntityList') {
  238. // // this.$refs.flow.setFieldValue('iamWorkPaperMaterialEntityList', JSON.parse(item.value))
  239. // }
  240. // })
  241. // },
  242. getConstruceFind(projectId) {
  243. // 获取发现列表
  244. const params = { projectId: projectId }
  245. axios({
  246. url: 'api/xcoa-mobile/v1/spicengineconstruceproject/baseFindBean',
  247. method: 'post',
  248. data: params,
  249. }).then((res) => {
  250. res.data.forEach((item, index) => {
  251. item.sortNum = index + 1
  252. })
  253. this.$refs.flow.setFieldValue('spicEngineConstruceProjectList', res.data)
  254. })
  255. },
  256. remove() {
  257. // debugger
  258. const mainId = this.$refs.flow.getFieldValue('id')
  259. const childData = this.$refs.flow.getFieldValue('spicEngineConstruceProjectList')
  260. const idList = []
  261. const ids = this.$refs.tabaData.selectedRowKeys
  262. if (!ids || ids.length === 0) {
  263. Modal.warning({
  264. title: '提示',
  265. content: '请至少选中一条数据!',
  266. })
  267. } else {
  268. ids.forEach((item) => {
  269. idList.push(childData[item].id)
  270. })
  271. return new Promise((resolve) => {
  272. Modal.confirm({
  273. title: '您确定删除这项内容吗?',
  274. content: '删除这条数据后,就无法恢复初始的状态。',
  275. okText: '删除',
  276. cancelText: '取消',
  277. okType: 'danger',
  278. onOk: () => {
  279. axios({
  280. url:
  281. 'api/xcoa-mobile/v1/spicengineconstruceproject/deleteById?ids=' +
  282. idList.join(','),
  283. method: 'post',
  284. })
  285. .then(() => {
  286. // this.$refs.tabaData.clearSelection()
  287. Message.success('删除成功')
  288. // this.$refs.tabaData.refresh()
  289. this.getConstruceFind(mainId)
  290. })
  291. .catch((err) => {
  292. const msg = errorUtil.getMessage(err) || '删除失败'
  293. Message.error(msg)
  294. })
  295. .finally(resolve)
  296. },
  297. onCancel: () => {
  298. resolve()
  299. },
  300. })
  301. })
  302. // ids.forEach((item) => {
  303. // idList.push(childData[item].id)
  304. // })
  305. // axios({
  306. // url: 'api/xcoa-mobile/v1/spicengineconstruceproject/deleteById?ids=' + idList.join(','),
  307. // method: 'post',
  308. // }).then((res) => {
  309. // if (res.data) {
  310. // Message.success('删除成功')
  311. // this.getConstruceFind(mainId)
  312. // }
  313. // })
  314. }
  315. },
  316. getProject() {
  317. // debugger
  318. const data = []
  319. axios({
  320. url: 'api/xcoa-mobile/v1/spicengineconstruceproject/all-list',
  321. method: 'post',
  322. }).then((res) => {
  323. if (res.status === 200) {
  324. res.data.forEach((element) => {
  325. // this.$refs.tabaData.value.push(element)
  326. data.push(element)
  327. })
  328. if (data.length > 0) {
  329. var saveButtons = this.$refs.flow.flowData.saveButtons
  330. var buttonId = ''
  331. saveButtons.forEach((item, index) => {
  332. if (item.buttonName === '保存') {
  333. buttonId = item.buttonId
  334. // console.log('-------buttonId-', buttonId)
  335. }
  336. })
  337. // Message.warn('自动保存中...')
  338. const button = {
  339. attrs: null,
  340. buttonId: buttonId,
  341. buttonName: '保存',
  342. fakeId: 'save',
  343. rollbackSteps: null,
  344. type: 'save',
  345. }
  346. const oldList = this.$refs.flow.getFieldValue('spicEngineConstruceProjectList')
  347. // console.log('-------旧数据-', oldList)
  348. const newList = data
  349. // console.log('-------新数据 -', newList)
  350. let list
  351. if (oldList !== undefined && oldList != null) {
  352. list = [...oldList, ...newList]
  353. } else {
  354. list = newList
  355. }
  356. this.$refs.flow.setFieldValue('spicEngineConstruceProjectList', list)
  357. // console.log('-------结果数据shuju-', list)
  358. this.$refs.flow.buttonClick(button)
  359. } else {
  360. Modal.warning({
  361. title: '提示',
  362. content: '没有可生成的数据!',
  363. })
  364. }
  365. }
  366. })
  367. },
  368. initData() {
  369. const mainId = this.$refs.flow.getFieldValue('id')
  370. const year = new Date().getFullYear()
  371. const month = new Date().getMonth() + 1
  372. if (mainId !== null && mainId !== undefined) {
  373. this.getConstruceFind(mainId)
  374. }
  375. if (mainId === undefined || mainId === '') {
  376. this.$refs.flow.setFieldValue('title', year + '年' + month + '月' + '工程建设项目')
  377. this.$refs.flow.setFieldValue('submitMonth', month + '月')
  378. }
  379. debugger
  380. if (
  381. this.$refs.flow.getFieldValue('submitUnit') === undefined ||
  382. this.$refs.flow.getFieldValue('submitUnit') === null ||
  383. this.$refs.flow.getFieldValue('submitUnit') === ''
  384. ) {
  385. let userInfo = getUserInfo()
  386. const vunits = []
  387. const params = {
  388. orgId: userInfo.deptId,
  389. }
  390. axios({
  391. url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup',
  392. method: 'get',
  393. }).then((res) => {
  394. userInfo = res.data
  395. params.orgId = res.data.id
  396. axios({
  397. url: 'api/xcoa-mobile/v1/iamorg/findIamOrg',
  398. method: 'post',
  399. params,
  400. }).then((res) => {
  401. const deptCode = res.data.orgId
  402. const deptName = res.data.orgName
  403. this.rootNode = { code: deptCode, name: deptName, id: res.data.id }
  404. vunits.push({
  405. type: 'Group',
  406. code: deptCode,
  407. name: deptName,
  408. })
  409. this.$refs.flow.setFieldValue('submitUnit', vunits)
  410. })
  411. })
  412. }
  413. },
  414. changedept() {
  415. let deptname = ''
  416. let deptCode = ''
  417. const value = this.$refs.flow.getFieldValue('submitUnit')
  418. if (value) {
  419. value.forEach((d) => {
  420. deptname += ',' + d.name
  421. deptCode += ',' + d.code
  422. })
  423. if (deptname !== '') deptname = deptname.substring(1, deptname.length)
  424. this.$refs.flow.setFieldValue('submitUnitName', deptname)
  425. if (deptCode !== '') deptCode = deptCode.substring(1, deptCode.length)
  426. this.$refs.flow.setFieldValue('submitUnitCode', deptCode)
  427. }
  428. },
  429. // validateForm() {
  430. // debugger
  431. // },
  432. changeUser() {
  433. let username = ''
  434. let userCode = ''
  435. const value = this.$refs.flow.getFieldValue('submitUser')
  436. if (value) {
  437. value.forEach((d) => {
  438. username += ',' + d.name
  439. userCode += ',' + d.code
  440. })
  441. if (username !== '') username = username.substring(1, username.length)
  442. this.$refs.flow.setFieldValue('submitUserName', username)
  443. if (userCode !== '') userCode = userCode.substring(1, userCode.length)
  444. this.$refs.flow.setFieldValue('submitUserCode', userCode)
  445. }
  446. },
  447. },
  448. }
  449. </script>
  450. <style module lang="scss">
  451. @use '@/common/design' as *;
  452. .odrForm {
  453. /* :global .sd-page-title {
  454. display: none;
  455. } */
  456. :global(.child-table-title) {
  457. display: none;
  458. }
  459. .lastTr {
  460. :global(.ant-form-item-control-wrapper) {
  461. border: none !important;
  462. }
  463. }
  464. :global(.header_sd-child-table_common) {
  465. right: 115px !important;
  466. }
  467. .btnexcel {
  468. position: relative;
  469. top: -5px;
  470. float: right;
  471. .batchexcel {
  472. z-index: 100;
  473. margin-left: 10px;
  474. }
  475. .autoprequeue {
  476. right: 180px;
  477. z-index: 100;
  478. }
  479. .viewSjjh {
  480. right: 180px;
  481. z-index: 100;
  482. }
  483. }
  484. :global(.ant-form-item-label > label) {
  485. width: 100% !important;
  486. white-space: normal;
  487. }
  488. }
  489. .projecttable {
  490. table {
  491. border-collapse: collapse;
  492. }
  493. }
  494. .iam-audit-child-table {
  495. :global(td.ant-form-item-label) {
  496. width: 15%;
  497. padding-right: 20px;
  498. overflow: auto;
  499. white-space: normal;
  500. }
  501. :global(td.ant-form-item-label::after) {
  502. position: absolute;
  503. margin: 0 8px 0 8px;
  504. content: ':';
  505. }
  506. :global(td.ant-form-item-label > label::after) {
  507. margin: 0;
  508. content: '';
  509. }
  510. :global(td.ant-form-item-control-wrapper) {
  511. width: 32%;
  512. }
  513. }
  514. :global(.auditplanformmodalcksjjh) {
  515. :global(.ant-pagination) {
  516. display: none;
  517. }
  518. }
  519. .btnselect {
  520. position: relative;
  521. float: right;
  522. .batchselect {
  523. z-index: 100;
  524. margin-right: 30px;
  525. top: 4px;
  526. }
  527. }
  528. </style>