spic-engine-construce-base.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <!-- <div class="auditsqapplylist"> -->
  3. <div>
  4. <a-card>
  5. <a-radio-group v-model="radioValue" allow-clear @change="radioOnChange">
  6. <a-radio :value="1">
  7. 全部
  8. </a-radio>
  9. <a-radio :value="2">
  10. 待处理
  11. </a-radio>
  12. </a-radio-group>
  13. <!-- 高级搜索组件 -->
  14. <audit-advanced-query
  15. :expand="expand"
  16. :search-data="formData"
  17. :ref-name="searchform"
  18. :search-style="{ height: '180px', left: '20px', top: '80px' }"
  19. :search-fun="handleSearch"
  20. @searchedClick="searchedClick"
  21. >
  22. <template>
  23. <a-col :span="12">
  24. <a-form-model-item :label="'报送单位'" prop="submitUnitName">
  25. <a-input v-model="formData.submitUnitName" allow-clear />
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :span="12">
  29. <a-form-model-item :label="'报送人'" prop="submitUserName">
  30. <a-input v-model="formData.submitUserName" allow-clear />
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :span="12">
  34. <a-form-model-item :label="'报送月份'" prop="submitMonth">
  35. <a-select
  36. v-model="formData.submitMonth"
  37. :options="monthOptions"
  38. allow-clear
  39. ></a-select>
  40. </a-form-model-item>
  41. <!-- <a-form-model-item :label="'报送月份'" prop="submitMonth">
  42. <a-input v-model="formData.submitMonth" allow-clear />
  43. </a-form-model-item> -->
  44. </a-col>
  45. <a-col :span="12">
  46. <a-form-model-item :label="'报送时间'" prop="submitDate">
  47. <a-range-picker v-model="formData.submitDate" />
  48. </a-form-model-item>
  49. </a-col>
  50. </template>
  51. </audit-advanced-query>
  52. <!-- <a-form-model>
  53. <a-row :gutter="24">
  54. <a-button type="primary" @click="projectExport">
  55. 查询
  56. </a-button>
  57. </a-row>
  58. </a-form-model> -->
  59. <sd-data-table-ex
  60. ref="projectFDataTable"
  61. :filter-expressions="expressions"
  62. :columns="columns"
  63. :actions="actions"
  64. form-id="spicEngineConstruceBase"
  65. data-url="api/xcoa-mobile/v1/spicengineconstrucebase/dataList"
  66. :search-fields="['submitUnitName', 'submitMonth', 'submitUserName']"
  67. show-selection
  68. :show-advance-query="true"
  69. @searchbtnClick="searchbtnClick"
  70. >
  71. <template slot="islink" slot-scope="text, record">
  72. <a :title="text" @click="rowClick(record)">{{ text }}</a>
  73. </template>
  74. </sd-data-table-ex>
  75. </a-card>
  76. </div>
  77. </template>
  78. <script>
  79. import download from '@/common/services/download'
  80. import axios from '@/common/services/axios-instance'
  81. import PageService from '@/common/services/page-service'
  82. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  83. import TableColumnTypes from '@/common/services/table-column-types'
  84. import TableActionTypes from '@/common/services/table-action-types'
  85. import { getUserInfo } from '@/common/store-mixin'
  86. import { message, Modal } from 'ant-design-vue'
  87. import auditAdvancedQueryMixins from '@product/iam/components/audit-advanced-query-mixins'
  88. import auditAdvancedGroupMixins from '@product/iam/components/audit-advanced-group-mixins'
  89. import auditAdvancedQuery from '@product/iam/components/audit-advanced-query.vue'
  90. import components from './_import-components/spic-engine-construce-base-import'
  91. export default {
  92. name: 'SpicEngineConstruceBase',
  93. metaInfo: {
  94. title: '工程建设项目',
  95. },
  96. components: {
  97. ...components,
  98. auditAdvancedQuery,
  99. },
  100. mixins: [auditAdvancedQueryMixins, auditAdvancedGroupMixins],
  101. data() {
  102. return {
  103. isCreateProject: true,
  104. radioValue: 1,
  105. expressions: [],
  106. searchform: 'searchform',
  107. formId: 'spicEngineConstruceBase',
  108. formData: {
  109. submitMonth: '',
  110. submitUnitName: '',
  111. submitUserName: '',
  112. submitDate: '',
  113. },
  114. monthOptions: [
  115. { value: '1', label: '1月' },
  116. { value: '2', label: '2月' },
  117. { value: '3', label: '3月' },
  118. { value: '4', label: '4月' },
  119. { value: '5', label: '5月' },
  120. { value: '6', label: '6月' },
  121. { value: '7', label: '7月' },
  122. { value: '8', label: '8月' },
  123. { value: '9', label: '9月' },
  124. { value: '10', label: '10月' },
  125. { value: '11', label: '11月' },
  126. { value: '12', label: '12月' },
  127. ],
  128. columns: [
  129. {
  130. title: '报送单位',
  131. dataIndex: 'submitUnitName',
  132. },
  133. {
  134. title: '报送月份',
  135. dataIndex: 'submitMonth',
  136. scopedSlots: { customRender: 'islink' },
  137. },
  138. {
  139. title: 'instId',
  140. dataIndex: 'instId',
  141. sdHidden: true,
  142. },
  143. {
  144. title: '报送人',
  145. dataIndex: 'submitUserName',
  146. },
  147. {
  148. title: '报送时间',
  149. dataIndex: 'submitDate',
  150. sdRender: TableColumnTypes.date,
  151. },
  152. {
  153. title: 'instId',
  154. dataIndex: 'instId',
  155. sdHidden: true,
  156. },
  157. {
  158. title: '当前状态',
  159. dataIndex: 'flowState',
  160. },
  161. {
  162. title: '当前处理人',
  163. dataIndex: 'currentUser',
  164. },
  165. ],
  166. actions: [
  167. {
  168. label: '新建',
  169. id: 'new',
  170. permission: 'create',
  171. type: TableActionTypes.primary,
  172. callback: () => {
  173. const url = '/sd-flow-guide?code=SPIC_AUDIT_GCJSXM' // 新页面要打开的路由地址
  174. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  175. if (refreshFlag) {
  176. // 这里写或者调刷新的方法
  177. this.refreshDataTable()
  178. }
  179. })
  180. },
  181. },
  182. {
  183. label: '删除',
  184. id: 'delete',
  185. permission: null,
  186. type: TableActionTypes.batch,
  187. callback: this.deleteRows,
  188. // type: TableActionTypes.ex.delete, // 删除按钮,不需要回调,会自动处理(对sd-data-table无效)
  189. },
  190. {
  191. label: '导出',
  192. permission: null, // 纯前端操作,不需要权限控制
  193. callback: () => {
  194. this.projectExport()
  195. },
  196. },
  197. ],
  198. }
  199. },
  200. methods: {
  201. // 判断数组或字符串为null或长度为0
  202. strOrArr(strOrArr) {
  203. return strOrArr !== null && strOrArr.length > 0
  204. },
  205. projectExport() {
  206. debugger
  207. this.expressions = []
  208. if (this.radioValue === 1) {
  209. this.expressions.push({
  210. dataType: 'str',
  211. name: 'stateFlag',
  212. op: 'eq',
  213. stringValue: 'true',
  214. })
  215. } else if (this.radioValue === 2) {
  216. this.expressions.push({
  217. dataType: 'str',
  218. name: 'stateFlag',
  219. op: 'eq',
  220. stringValue: 'false',
  221. })
  222. }
  223. // 报送单位
  224. if (this.formData.submitUnitName) {
  225. this.expressions.push({
  226. dataType: 'str',
  227. name: 'submitUnitName',
  228. op: 'like',
  229. stringValue: `${this.formData.submitUnitName}`,
  230. })
  231. }
  232. // 报送月份
  233. if (this.formData.submitMonth) {
  234. this.expressions.push({
  235. dataType: 'str',
  236. name: 'submitMonth',
  237. op: 'eq',
  238. stringValue: `${this.formData.submitMonth}`,
  239. })
  240. }
  241. // 报送人
  242. if (this.formData.submitUserName) {
  243. this.expressions.push({
  244. dataType: 'str',
  245. name: 'submitUserName',
  246. op: 'like',
  247. stringValue: `${this.formData.submitUserName}`,
  248. })
  249. }
  250. // 报送时间
  251. if (this.strOrArr(this.formData.submitDate)) {
  252. if (this.formData.submitDate[0] === null || this.formData.submitDate[0] === '') {
  253. this.formData.submitDate = null
  254. } else {
  255. this.expressions.push({
  256. dataType: 'str',
  257. name: 'submitDate',
  258. op: 'ge',
  259. stringValue: `${this.formData.submitDate[0].format('YYYY-MM-DD')}`,
  260. })
  261. this.expressions.push({
  262. dataType: 'str',
  263. name: 'submitDate',
  264. op: 'le',
  265. stringValue: `${this.formData.submitDate[1].format('YYYY-MM-DD')}`,
  266. })
  267. }
  268. }
  269. axios({
  270. method: 'post',
  271. url: 'api/xcoa-mobile/v1/spicengineconstrucebase/exportDataList',
  272. responseType: 'blob',
  273. data: this.expressions,
  274. headers: {
  275. 'Content-Type': 'application/json',
  276. },
  277. }).then((res) => {
  278. const url = URL.createObjectURL(res.data)
  279. download(url, '集团公司在审重点工程建设项目信息表.xlsx')
  280. })
  281. },
  282. radioOnChange(e) {
  283. if (this.selectedType !== e.target.value) {
  284. this.expressions = []
  285. this.selectedType = e.target.value
  286. if (e.target.value === 1) {
  287. this.expressions.push({
  288. dataType: 'str',
  289. name: 'stateFlag',
  290. op: 'eq',
  291. stringValue: 'true',
  292. })
  293. } else if (e.target.value === 2) {
  294. this.expressions.push({
  295. dataType: 'str',
  296. name: 'stateFlag',
  297. op: 'eq',
  298. stringValue: 'false',
  299. })
  300. }
  301. }
  302. this.$refs.sqapplyDataTable.clearSelection()
  303. },
  304. // 查询
  305. handleSearch() {
  306. this.expressions = []
  307. if (this.radioValue === 1) {
  308. this.expressions.push({
  309. dataType: 'str',
  310. name: 'stateFlag',
  311. op: 'eq',
  312. stringValue: 'true',
  313. })
  314. } else if (this.radioValue === 2) {
  315. this.expressions.push({
  316. dataType: 'str',
  317. name: 'stateFlag',
  318. op: 'eq',
  319. stringValue: 'false',
  320. })
  321. }
  322. // 报送单位
  323. if (this.formData.submitUnitName) {
  324. this.expressions.push({
  325. dataType: 'str',
  326. name: 'submitUnitName',
  327. op: 'like',
  328. stringValue: `${this.formData.submitUnitName}`,
  329. })
  330. }
  331. // 报送月份
  332. if (this.formData.submitMonth) {
  333. this.expressions.push({
  334. dataType: 'str',
  335. name: 'submitMonth',
  336. op: 'eq',
  337. stringValue: `${this.formData.submitMonth}`,
  338. })
  339. }
  340. // 报送人
  341. if (this.formData.submitUserName) {
  342. this.expressions.push({
  343. dataType: 'str',
  344. name: 'submitUserName',
  345. op: 'like',
  346. stringValue: `${this.formData.submitUserName}`,
  347. })
  348. }
  349. // 报送时间
  350. if (this.strOrArr(this.formData.submitDate)) {
  351. if (this.formData.submitDate[0] === null || this.formData.submitDate[0] === '') {
  352. this.formData.submitDate = null
  353. } else {
  354. this.expressions.push({
  355. dataType: 'str',
  356. name: 'submitDate',
  357. op: 'ge',
  358. stringValue: `${this.formData.submitDate[0].format('YYYY-MM-DD')}`,
  359. })
  360. this.expressions.push({
  361. dataType: 'str',
  362. name: 'submitDate',
  363. op: 'le',
  364. stringValue: `${this.formData.submitDate[1].format('YYYY-MM-DD')}`,
  365. })
  366. }
  367. }
  368. },
  369. // 删除数据
  370. deleteRows(record) {
  371. const userInfo = getUserInfo()
  372. const selecteFlowState = this.$refs.projectFDataTable.getSelectedRows()
  373. const selectedRowKeys = this.$refs.projectFDataTable.getSelectedRowKeys()
  374. if (selectedRowKeys.length === 0) {
  375. Modal.info({
  376. content: '请选择需要删除的数据!',
  377. })
  378. return
  379. }
  380. axios({
  381. url: 'api/xcoa-mobile/v1/spicengineconstrucebase/findHasPermission',
  382. method: 'post',
  383. }).then((res) => {
  384. if (res.data === true) {
  385. this.flagdelete()
  386. } else {
  387. let delFlag = true
  388. selecteFlowState.forEach((item) => {
  389. if (item.creatorName !== userInfo.name) {
  390. delFlag = false
  391. }
  392. })
  393. if (delFlag) {
  394. this.flagdelete()
  395. } else {
  396. Modal.warning({
  397. title: '提示',
  398. content: '删除失败,不可删除他人创建的流程!',
  399. })
  400. }
  401. }
  402. })
  403. },
  404. flagdelete() {
  405. let flag = true
  406. const rows = this.$refs.projectFDataTable.getSelectedRows()
  407. rows.forEach((r) => {
  408. if (r.endType) {
  409. if (r.endType !== 0) {
  410. flag = false
  411. }
  412. }
  413. })
  414. if (!flag) {
  415. Modal.error({
  416. title: '删除失败:存在不是起草状态的数据',
  417. })
  418. this.loading = false
  419. } else {
  420. const selectedRowKeys = this.$refs.projectFDataTable.getSelectedRowKeys()
  421. Modal.confirm({
  422. title: '你确定删除这项内容吗?',
  423. content: '删除这条数据后,就无法恢复初始的状态。',
  424. okText: '删除',
  425. okType: 'danger',
  426. onOk: () => {
  427. this.loading = true
  428. const params = {
  429. ids: selectedRowKeys.join(','),
  430. }
  431. PageService.delete(params, this.formId).then((res) => {
  432. message.success('删除成功')
  433. if (res.status === 200) {
  434. this.$refs.projectFDataTable.clearSelection()
  435. this.refresh()
  436. this.loading = false
  437. }
  438. })
  439. },
  440. })
  441. }
  442. },
  443. refresh() {
  444. return this.$refs.projectFDataTable.refresh(true)
  445. },
  446. rowClick(record) {
  447. if (record.flowState === '起草' && record.creatorAccount === getUserInfo().account) {
  448. const url = '/sd-webflow/pages/draft/' + record.instId // 编辑面要打开的路由地址
  449. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  450. if (refreshFlag) {
  451. // 这里写或者调刷新的方法
  452. this.refreshDataTable()
  453. }
  454. })
  455. } else {
  456. const url = '/sd-webflow/done-pages/' + record.instId
  457. crossWindowWatcher.waitForChanged(url).then((refreshFlag) => {
  458. if (refreshFlag) {
  459. // 这里写或者调刷新的方法
  460. this.refreshDataTable()
  461. }
  462. })
  463. }
  464. },
  465. refreshDataTable() {
  466. this.$refs.projectFDataTable.clearSelection()
  467. this.$refs.projectFDataTable.refresh()
  468. },
  469. },
  470. }
  471. </script>
  472. <style module lang="scss">
  473. @use '@/common/design' as *;
  474. :global(.auditsqapplylist) {
  475. :global(span > .ant-btn:last-child) {
  476. color: #fff;
  477. background-color: #1890ff;
  478. border-color: #1890ff;
  479. }
  480. :global(.ant-radio-group) {
  481. // position: relative;
  482. // top: 40px;
  483. float: left;
  484. line-height: 40px;
  485. }
  486. }
  487. </style>