PurchasePlan.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="8" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator" style="margin-bottom: 8px;">
  22. <a-button v-if="$auth('purchase-purchase-plans-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  23. <a-button style="margin-left: 8px" v-if="$auth('purchase-purchase-plans-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  24. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-plans-del')">
  25. <a-menu slot="overlay">
  26. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  27. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  28. </a-popconfirm>
  29. </a-menu>
  30. <a-button style="margin-left: 8px">
  31. 批量操作 <a-icon type="down" />
  32. </a-button>
  33. </a-dropdown>
  34. </div>
  35. <s-table
  36. ref="table"
  37. size="small"
  38. rowKey="id"
  39. :columns="columns"
  40. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  41. :data="loadData"
  42. :alert="options.alert"
  43. :rowSelection="options.rowSelection"
  44. showPagination="auto"
  45. >
  46. <span slot="action" slot-scope="record">
  47. <template>
  48. <a @click="handleView(record)">查看</a>
  49. <operation-button
  50. v-if="$auth('purchase-purchase-plans-edit') && getUpdateFlag(record.status)"
  51. @click="handleEdit(record)"
  52. >修改</operation-button>
  53. <operation-button
  54. v-if="DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_DTJ < record.status"
  55. @click="handlePrint(record)"
  56. >打印</operation-button>
  57. <operation-button
  58. v-if="$auth('purchase-purchase-plans-edit') && DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_YWC === record.status"
  59. @click="handleQuantity(record.id)"
  60. >调整数量</operation-button>
  61. <operation-button
  62. v-if="$auth('purchase-purchase-plans-edit') && getUpdateFlag(record.status)"
  63. :type="2"
  64. title="提交审批操作过后将无法更改,确认进行该操作吗?"
  65. @confirm="handleSubmit(record.id)">提交审批</operation-button>
  66. <!-- <operation-button-->
  67. <!-- v-if="$auth('purchase-purchase-plans-edit') && DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_SHE === record.status"-->
  68. <!-- @click="handleAudit(record)"-->
  69. <!-- >审批</operation-button>-->
  70. <operation-button
  71. v-if="$auth('purchase-purchase-plans-del') && DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_DTJ === record.status"
  72. :type="2"
  73. title="是否要删除该条数据?"
  74. @confirm="batchDelete(record.id)">删除</operation-button>
  75. </template>
  76. </span>
  77. </s-table>
  78. </div>
  79. <base-form ref="basePlanModal" @ok="handleOk"/>
  80. <print-form ref="basePrintModal" @ok="handleOk"/>
  81. <audit-form ref="auditPlanModal" @ok="handleOk"/>
  82. <detail ref="detailPlanModal" @ok="handleOk"/>
  83. <purchase-plan-list-for-quantity ref="planListQuantityModal" @ok="handleOk"/>
  84. </a-card>
  85. </template>
  86. <script>
  87. import { STable, Ellipsis } from '@/components'
  88. import BaseForm from './modules/BaseFormStep'
  89. import PrintForm from './modules/PrintForm'
  90. import Detail from './modules/Detail'
  91. import AuditForm from './modules/AuditForm'
  92. import PurchasePlanListForQuantity from './PurchasePlanListForQuantity'
  93. import { getPurchasePlanPage, deletePurchasePlans, fetchPurchasePlan, exportPurchasePlan, submit } from '@/api/purchase/purchase-plan'
  94. export default {
  95. name: 'PurchasePlan',
  96. components: {
  97. STable,
  98. Ellipsis,
  99. BaseForm,
  100. PrintForm,
  101. AuditForm,
  102. PurchasePlanListForQuantity,
  103. Detail
  104. },
  105. data () {
  106. return {
  107. // 查询参数
  108. queryParam: {
  109. },
  110. visible: true,
  111. dollarExchangeRate: this.$store.getters.rmbRate,
  112. // 表头
  113. columns: [
  114. {
  115. title: '序号',
  116. dataIndex: 'index',
  117. checked: true,
  118. width: 70,
  119. customRender: (text, record, index) => {
  120. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  121. }
  122. },
  123. {
  124. title: '单号',
  125. dataIndex: 'billNo',
  126. checked: true,
  127. width: 150
  128. },
  129. {
  130. title: '计划名称',
  131. dataIndex: 'name',
  132. checked: true,
  133. width: 150
  134. },
  135. {
  136. title: '项目名称',
  137. dataIndex: 'projectName',
  138. checked: true,
  139. width: 150
  140. },
  141. {
  142. title: '数量',
  143. dataIndex: 'quantity',
  144. checked: true,
  145. width: 150,
  146. customRender: (text, record, index) => {
  147. return this.BaseTool.Amount.formatter(text)
  148. }
  149. },
  150. {
  151. title: '已购数量',
  152. dataIndex: 'boughtQuantity',
  153. width: 150,
  154. checked: true,
  155. customRender: (text, record, index) => {
  156. return this.BaseTool.Amount.formatter(text)
  157. }
  158. },
  159. {
  160. title: '已到数量',
  161. dataIndex: 'arrivedQuantity',
  162. width: 150,
  163. checked: true,
  164. customRender: (text, record, index) => {
  165. return this.BaseTool.Amount.formatter(text)
  166. }
  167. },
  168. {
  169. title: '未到数量',
  170. dataIndex: 'notArriveQuantity',
  171. width: 150,
  172. customRender: (text, record, index) => {
  173. return this.BaseTool.Amount.formatter(text)
  174. }
  175. },
  176. {
  177. title: '计划总金额',
  178. dataIndex: 'planMoney',
  179. checked: true,
  180. width: 150,
  181. customRender: (text, record, index) => {
  182. let dollarExchangeRate = 1
  183. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  184. dollarExchangeRate = this.dollarExchangeRate
  185. }
  186. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  187. }
  188. },
  189. {
  190. title: '已询价金额',
  191. dataIndex: 'money',
  192. checked: true,
  193. width: 150,
  194. customRender: (text, record, index) => {
  195. let dollarExchangeRate = 1
  196. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  197. dollarExchangeRate = this.dollarExchangeRate
  198. }
  199. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  200. }
  201. },
  202. {
  203. title: '已用金额',
  204. dataIndex: 'usedMoney',
  205. checked: true,
  206. width: 150,
  207. customRender: (text, record, index) => {
  208. let dollarExchangeRate = 1
  209. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  210. dollarExchangeRate = this.dollarExchangeRate
  211. }
  212. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  213. }
  214. },
  215. {
  216. title: '项目记账币种',
  217. dataIndex: 'projectMoneyType',
  218. checked: true,
  219. width: 120,
  220. customRender: (text, record, index) => {
  221. return this.BaseTool.Table.getMapText(this.moneyTypeMap, text)
  222. }
  223. },
  224. {
  225. title: '类型',
  226. dataIndex: 'type',
  227. checked: true,
  228. width: 90,
  229. customRender: (text, record, index) => {
  230. return this.BaseTool.Table.getMapText(this.typeMap, text)
  231. }
  232. },
  233. {
  234. title: '公司名称',
  235. dataIndex: 'companyName',
  236. checked: true,
  237. width: 150
  238. },
  239. {
  240. title: '需求计划名称',
  241. dataIndex: 'demandPlanName',
  242. checked: true,
  243. width: 150
  244. },
  245. {
  246. title: '呈报',
  247. dataIndex: 'reportType',
  248. checked: true,
  249. width: 150,
  250. customRender: (text, record, index) => {
  251. return this.BaseTool.Table.getMapText(this.reportTypeMap, text)
  252. }
  253. },
  254. {
  255. title: '需求日期',
  256. dataIndex: 'demandDate',
  257. checked: true,
  258. width: 150
  259. },
  260. // {
  261. // title: '事项',
  262. // dataIndex: 'item',
  263. // width: 150
  264. // },
  265. // {
  266. // title: '设备物资综述',
  267. // dataIndex: 'summary',
  268. // width: 150
  269. // },
  270. // {
  271. // title: '特殊情况',
  272. // dataIndex: 'specialDescription',
  273. // width: 150
  274. // },
  275. {
  276. title: '进度',
  277. dataIndex: 'progress',
  278. width: 150,
  279. customRender: (text, record, index) => {
  280. return this.BaseTool.Amount.formatter(text)
  281. }
  282. },
  283. {
  284. title: '总重',
  285. dataIndex: 'totalWeight',
  286. width: 150,
  287. customRender: (text, record, index) => {
  288. return this.BaseTool.Amount.formatter(text)
  289. }
  290. },
  291. {
  292. title: '总体积',
  293. dataIndex: 'totalVolume',
  294. width: 150,
  295. customRender: (text, record, index) => {
  296. return this.BaseTool.Amount.formatter(text)
  297. }
  298. },
  299. {
  300. title: '申请时间',
  301. checked: true,
  302. dataIndex: 'applyTime',
  303. width: 150
  304. },
  305. {
  306. title: '审批通过时间',
  307. checked: true,
  308. dataIndex: 'auditTime',
  309. width: 150
  310. },
  311. {
  312. title: '审批节点',
  313. dataIndex: 'auditNode',
  314. fixed: 'right',
  315. checked: true,
  316. width: 100,
  317. customRender: (text, record, index) => {
  318. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  319. this.DictCache.COLOR.PURCHASE_AUDIT_NODE, this.nodeMap)
  320. }
  321. },
  322. {
  323. title: '状态',
  324. dataIndex: 'status',
  325. fixed: 'right',
  326. checked: true,
  327. width: 100,
  328. customRender: (text, record, index) => {
  329. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  330. this.DictCache.COLOR.PURCHASE_PLAN_STATUS, this.statusMap)
  331. }
  332. },
  333. {
  334. title: '备注',
  335. dataIndex: 'remark',
  336. width: 150
  337. },
  338. {
  339. title: '创建人名称',
  340. dataIndex: 'createdUserName',
  341. width: 150
  342. },
  343. {
  344. title: '创建时间',
  345. dataIndex: 'createdTime',
  346. width: 150
  347. },
  348. {
  349. title: '操作',
  350. key: 'action',
  351. width: '200px',
  352. fixed: 'right',
  353. checked: true,
  354. align: 'center',
  355. scopedSlots: { customRender: 'action' }
  356. }
  357. ],
  358. // 下拉框map
  359. typeMap: {},
  360. reportTypeMap: {},
  361. periodTypeMap: {},
  362. nodeMap: {},
  363. moneyTypeMap: {},
  364. // 加载数据方法 必须为 Promise 对象
  365. loadData: parameter => {
  366. const user = this.$store.getters.userInfo
  367. const roleCodes = user.roleCodes.join(',')
  368. parameter = {
  369. ...parameter,
  370. ...this.queryParam,
  371. projectId: roleCodes.indexOf('FGS_') > -1 ? null : user.projectId,
  372. dataScope: {
  373. sortBy: 'asc,desc',
  374. sortName: 'status,update_time'
  375. }
  376. }
  377. return getPurchasePlanPage(Object.assign(parameter, this.queryParam))
  378. .then(res => {
  379. return res.data
  380. })
  381. },
  382. selectedRowKeys: [],
  383. selectedRows: [],
  384. options: {
  385. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  386. rowSelection: {
  387. selectedRowKeys: this.selectedRowKeys,
  388. onChange: this.onSelectChange
  389. }
  390. },
  391. optionAlertShow: false
  392. }
  393. },
  394. created () {
  395. // 下拉框map
  396. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_TYPE)
  397. this.reportTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPORT_RANK)
  398. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_PERIOD_TYPE)
  399. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_PLAN_STATUS)
  400. this.nodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_AUDIT_NODE)
  401. this.moneyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.MONEY_TYPE)
  402. this.tableOption()
  403. },
  404. methods: {
  405. getUpdateFlag (status) {
  406. return this.DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_DTJ === status || this.DictCache.VALUE.PURCHASE_PLAN_STATUS.PURCHASE_PLAN_STATUS_SPBTG === status
  407. },
  408. tableOption () {
  409. if (!this.optionAlertShow) {
  410. this.options = {
  411. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  412. rowSelection: {
  413. selectedRowKeys: this.selectedRowKeys,
  414. onChange: this.onSelectChange,
  415. getCheckboxProps: record => ({
  416. props: {
  417. disabled: false,
  418. name: record.id
  419. }
  420. })
  421. }
  422. }
  423. this.optionAlertShow = true
  424. } else {
  425. this.options = {
  426. alert: false,
  427. rowSelection: null
  428. }
  429. this.optionAlertShow = false
  430. }
  431. },
  432. batchDelete (id) {
  433. let ids = []
  434. if (this.BaseTool.String.isBlank(id)) {
  435. const length = this.selectedRows.length
  436. if (length === 0) {
  437. this.$message.info('请选择要删除的记录')
  438. return
  439. }
  440. ids = this.selectedRows.map(item => item.id)
  441. } else {
  442. ids = [id]
  443. }
  444. deletePurchasePlans(ids).then(res => {
  445. this.$message.info('删除成功')
  446. this.handleOk()
  447. this.$refs.table.clearSelected()
  448. })
  449. },
  450. handleSubmit (id) {
  451. submit(id).then(res => {
  452. this.$message.info('提交成功')
  453. this.handleOk()
  454. })
  455. },
  456. handleAudit (record) {
  457. fetchPurchasePlan({ id: record.id }).then(res => {
  458. const modal = this.$refs.auditPlanModal
  459. this.visible = false
  460. modal.base(res.data)
  461. })
  462. },
  463. handleAdd () {
  464. this.visible = false
  465. this.$refs.basePlanModal.base()
  466. },
  467. handleEdit (record) {
  468. fetchPurchasePlan({ id: record.id }).then(res => {
  469. const modal = this.$refs.basePlanModal
  470. this.visible = false
  471. modal.base(res.data)
  472. })
  473. },
  474. handlePrint (record) {
  475. const modal = this.$refs.basePrintModal
  476. this.visible = false
  477. modal.base(record)
  478. },
  479. handleQuantity (id) {
  480. this.visible = false
  481. this.$refs.planListQuantityModal.base(id)
  482. },
  483. handleView (record) {
  484. fetchPurchasePlan({ id: record.id }).then(res => {
  485. const modal = this.$refs.detailPlanModal
  486. this.visible = false
  487. modal.base(res.data)
  488. })
  489. },
  490. handleOk () {
  491. this.visible = true
  492. this.$refs.table.refresh()
  493. },
  494. onSelectChange (selectedRowKeys, selectedRows) {
  495. this.selectedRowKeys = selectedRowKeys
  496. this.selectedRows = selectedRows
  497. },
  498. resetSearchForm () {
  499. this.queryParam = {
  500. }
  501. this.$refs.table.refresh(true)
  502. },
  503. doExport () {
  504. const parameter = {
  505. ...this.queryParam
  506. }
  507. exportPurchasePlan(parameter).then(file => {
  508. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  509. })
  510. },
  511. handleEnter () {
  512. this.$refs.table.refresh(true)
  513. }
  514. }
  515. }
  516. </script>