PurchaseApplyOrder.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div>
  3. <a-card :bordered="false" title="采购单" v-if="visible">
  4. <a-row :gutter="48" slot="extra">
  5. <a-col :md="48" :sm="48">
  6. <span class="table-page-search-submitButtons" style="float: right">
  7. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  8. </span>
  9. </a-col>
  10. </a-row>
  11. <title-divider title="采购申请信息" width="110px"></title-divider>
  12. <detail-list title="" :col="3">
  13. <detail-list-item term="单号">{{ record.billNo }}</detail-list-item>
  14. <detail-list-item term="公司名称">{{ record.companyName }}</detail-list-item>
  15. <detail-list-item term="项目名称">{{ record.projectName }}</detail-list-item>
  16. <detail-list-item term="类型">{{ BaseTool.Object.getField(typeMap,record.type) }}</detail-list-item>
  17. <detail-list-item term="呈报">{{ BaseTool.Object.getField(reportTypeMap,record.reportType) }}</detail-list-item>
  18. <detail-list-item term="需求日期">{{ record.demandDate }}</detail-list-item>
  19. <detail-list-item term="事项">{{ record.item }}</detail-list-item>
  20. <detail-list-item term="状态"><badge :status="DictCache.COLOR.PURCHASE_APPLY_STATUS[record.status]" :text="applyStatusMap[record.status]"></badge></detail-list-item>
  21. </detail-list>
  22. <detail-list title="" :col="1">
  23. <detail-list-item term="设备物资综述">{{ record.summary }}</detail-list-item>
  24. </detail-list>
  25. <detail-list title="" :col="1">
  26. <detail-list-item term="特殊情况">{{ record.specialDescription }}</detail-list-item>
  27. </detail-list>
  28. <title-divider title="采购单" width="80px"></title-divider>
  29. <!-- <div class="table-page-search-wrapper" @keyup.enter="handleEnter">-->
  30. <!-- <a-form layout="inline">-->
  31. <!-- <a-row :gutter="48">-->
  32. <!-- <a-col :md="8" :sm="24">-->
  33. <!-- <a-form-item label="关键字">-->
  34. <!-- <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>-->
  35. <!-- </a-form-item>-->
  36. <!-- </a-col>-->
  37. <!-- <a-col :md="8 || 24" :sm="24">-->
  38. <!-- <span class="table-page-search-submitButtons">-->
  39. <!-- <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>-->
  40. <!-- <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>-->
  41. <!-- </span>-->
  42. <!-- </a-col>-->
  43. <!-- </a-row>-->
  44. <!-- </a-form>-->
  45. <!-- </div>-->
  46. <div class="table-operator" style="margin-bottom: 8px;">
  47. <a-button v-if="$auth('purchase-purchase-orders-add')" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  48. <a-button style="margin-left: 8px" v-if="$auth('purchase-purchase-orders-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  49. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-del')">
  50. <a-menu slot="overlay">
  51. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  52. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  53. </a-popconfirm>
  54. </a-menu>
  55. <a-button style="margin-left: 8px">
  56. 批量操作 <a-icon type="down" />
  57. </a-button>
  58. </a-dropdown>
  59. </div>
  60. <s-table
  61. ref="table"
  62. size="default"
  63. rowKey="id"
  64. :columns="columns"
  65. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  66. :data="loadData"
  67. :alert="options.alert"
  68. :rowSelection="options.rowSelection"
  69. showPagination="auto"
  70. >
  71. <span slot="action" slot-scope="record">
  72. <template>
  73. <a @click="handleView(record)">查看</a>
  74. <operation-button
  75. v-if="$auth('purchase-purchase-orders-edit') && record.status == DictCache.VALUE.PURCHASE_ORDER_STATUS.PURCHASE_ORDER_STATUS_DXJ"
  76. @click="handleEdit(record)"
  77. >修改</operation-button>
  78. <operation-button
  79. v-if="$auth('purchase-purchase-orders-del') && record.status == DictCache.VALUE.PURCHASE_ORDER_STATUS.PURCHASE_ORDER_STATUS_DXJ"
  80. :type="2"
  81. title="是否要删除该条数据?"
  82. @confirm="batchDelete(record.id)">删除</operation-button>
  83. </template>
  84. </span>
  85. </s-table>
  86. </a-card>
  87. <base-form ref="baseModal" @ok="handleOk"/>
  88. <detail ref="detailModal" @ok="handleOk"/>
  89. </div>
  90. </template>
  91. <script>
  92. import { STable, Ellipsis } from '@/components'
  93. import BaseForm from './order-modules/BaseForm'
  94. import Detail from './order-modules/Detail'
  95. import { getPurchaseOrderPage, deletePurchaseOrders, fetchPurchaseOrder, exportPurchaseOrder } from '@/api/purchase/purchase-order'
  96. import DetailList from '@/components/tools/DetailList'
  97. const DetailListItem = DetailList.Item
  98. export default {
  99. name: 'PurchaseApplyOrder',
  100. components: {
  101. STable,
  102. Ellipsis,
  103. BaseForm,
  104. DetailList,
  105. DetailListItem,
  106. Detail
  107. },
  108. data () {
  109. return {
  110. // 查询参数
  111. queryParam: {
  112. },
  113. record: {},
  114. dollarExchangeRate: this.$store.getters.rmbRate,
  115. visible: false,
  116. // 表头
  117. columns: [
  118. {
  119. title: '序号',
  120. dataIndex: 'index',
  121. checked: true,
  122. width: 70,
  123. customRender: (text, record, index) => {
  124. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  125. }
  126. },
  127. {
  128. title: '单号',
  129. dataIndex: 'billNo',
  130. checked: true,
  131. width: 200
  132. },
  133. {
  134. title: '公司名称',
  135. dataIndex: 'companyName',
  136. checked: true,
  137. width: 150
  138. },
  139. {
  140. title: '项目名称',
  141. dataIndex: 'projectName',
  142. checked: true,
  143. width: 150
  144. },
  145. {
  146. title: '项目记账币种',
  147. dataIndex: 'projectMoneyType',
  148. checked: true,
  149. width: 120,
  150. customRender: (text, record, index) => {
  151. return this.BaseTool.Table.getMapText(this.moneyTypeMap, text)
  152. }
  153. },
  154. {
  155. title: '类型',
  156. dataIndex: 'type',
  157. checked: true,
  158. width: 100,
  159. customRender: (text, record, index) => {
  160. return this.BaseTool.Table.getMapText(this.typeMap, text)
  161. }
  162. },
  163. {
  164. title: '需求日期',
  165. dataIndex: 'demandDate',
  166. checked: true,
  167. width: 150
  168. },
  169. {
  170. title: '采购员名称',
  171. dataIndex: 'purchaserName',
  172. checked: true,
  173. width: 150
  174. },
  175. {
  176. title: '预计总金额',
  177. dataIndex: 'originMoney',
  178. checked: true,
  179. width: 120,
  180. customRender: (text, record, index) => {
  181. let dollarExchangeRate = 1
  182. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  183. dollarExchangeRate = this.dollarExchangeRate
  184. }
  185. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  186. }
  187. },
  188. {
  189. title: '实际总金额(按记账主币)',
  190. dataIndex: 'accountMoney',
  191. width: 120,
  192. customRender: (text, record, index) => {
  193. let dollarExchangeRate = 1
  194. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  195. dollarExchangeRate = this.dollarExchangeRate
  196. }
  197. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  198. }
  199. },
  200. {
  201. title: '实际总金额(按询价主币)',
  202. dataIndex: 'money',
  203. width: 120,
  204. customRender: (text, record, index) => {
  205. let dollarExchangeRate = 1
  206. if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
  207. dollarExchangeRate = this.dollarExchangeRate
  208. }
  209. return this.BaseTool.Amount.formatter(text) + this.BaseTool.Number.divForDollar(text, dollarExchangeRate, 2)
  210. }
  211. },
  212. {
  213. title: '询价币种',
  214. dataIndex: 'moneyType',
  215. width: 120,
  216. customRender: (text, record, index) => {
  217. return this.BaseTool.Table.getMapText(this.moneyTypeMap, text)
  218. }
  219. },
  220. {
  221. title: '数量',
  222. dataIndex: 'quantity',
  223. checked: true,
  224. width: 90,
  225. customRender: (text, record, index) => {
  226. return this.BaseTool.Amount.formatter(text)
  227. }
  228. },
  229. {
  230. title: '状态',
  231. dataIndex: 'status',
  232. checked: true,
  233. width: 150,
  234. customRender: (text, record, index) => {
  235. return this.BaseTool.Table.statusCustomRenderDict(this, text, record,
  236. this.DictCache.COLOR.PURCHASE_ORDER_STATUS, this.statusMap)
  237. }
  238. },
  239. {
  240. title: '备注',
  241. width: 100,
  242. dataIndex: 'remark'
  243. },
  244. {
  245. title: '操作',
  246. key: 'action',
  247. width: '200px',
  248. fixed: 'right',
  249. checked: true,
  250. align: 'center',
  251. scopedSlots: { customRender: 'action' }
  252. }
  253. ],
  254. // 下拉框map
  255. typeMap: {},
  256. reportTypeMap: {},
  257. moneyTypeMap: {},
  258. purchaseApplyId: '-1',
  259. statusMap: {},
  260. applyStatusMap: {},
  261. payTypeMap: {},
  262. invoiceTypeMap: {},
  263. isCreated: false,
  264. // 加载数据方法 必须为 Promise 对象
  265. loadData: parameter => {
  266. parameter = {
  267. ...parameter,
  268. ...this.queryParam,
  269. purchaseApplyId: this.purchaseApplyId,
  270. dataScope: {
  271. sortBy: 'asc,desc',
  272. sortName: 'status,update_time'
  273. }
  274. }
  275. return getPurchaseOrderPage(Object.assign(parameter, this.queryParam))
  276. .then(res => {
  277. return res.data
  278. })
  279. },
  280. selectedRowKeys: [],
  281. selectedRows: [],
  282. options: {
  283. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  284. rowSelection: {
  285. selectedRowKeys: this.selectedRowKeys,
  286. onChange: this.onSelectChange
  287. }
  288. },
  289. optionAlertShow: false
  290. }
  291. },
  292. created () {
  293. // 下拉框map
  294. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_APPLY_TYPE)
  295. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_ORDER_STATUS)
  296. this.applyStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_APPLY_STATUS)
  297. this.payTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_PAY_TYPE)
  298. this.invoiceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_INVOICE_TYPE)
  299. this.reportTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPORT_RANK)
  300. this.moneyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.MONEY_TYPE)
  301. this.tableOption()
  302. },
  303. methods: {
  304. base (record) {
  305. this.visible = true
  306. this.record = record
  307. this.purchaseApplyId = record.id
  308. if (this.isCreated) {
  309. this.handleOk()
  310. } else {
  311. this.tableOption()
  312. this.isCreated = true
  313. }
  314. },
  315. handleAdd () {
  316. this.visible = false
  317. this.$refs.baseModal.base(null, this.record, this.purchaseApplyId)
  318. },
  319. tableOption () {
  320. if (!this.optionAlertShow) {
  321. this.options = {
  322. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  323. rowSelection: {
  324. selectedRowKeys: this.selectedRowKeys,
  325. onChange: this.onSelectChange,
  326. getCheckboxProps: record => ({
  327. props: {
  328. disabled: false,
  329. name: record.id
  330. }
  331. })
  332. }
  333. }
  334. this.optionAlertShow = true
  335. } else {
  336. this.options = {
  337. alert: false,
  338. rowSelection: null
  339. }
  340. this.optionAlertShow = false
  341. }
  342. },
  343. batchDelete (id) {
  344. let ids = []
  345. if (this.BaseTool.String.isBlank(id)) {
  346. const length = this.selectedRows.length
  347. if (length === 0) {
  348. this.$message.info('请选择要删除的记录')
  349. return
  350. }
  351. ids = this.selectedRows.map(item => item.id)
  352. } else {
  353. ids = [id]
  354. }
  355. deletePurchaseOrders(ids).then(res => {
  356. this.$message.info('删除成功')
  357. this.handleOk()
  358. this.$refs.table.clearSelected()
  359. })
  360. },
  361. handleEdit (record) {
  362. fetchPurchaseOrder({ id: record.id }).then(res => {
  363. const modal = this.$refs.baseModal
  364. this.visible = false
  365. modal.base(res.data, this.record, this.purchaseApplyId)
  366. })
  367. },
  368. handleView (record) {
  369. fetchPurchaseOrder({ id: record.id }).then(res => {
  370. const modal = this.$refs.detailModal
  371. this.visible = false
  372. modal.base(res.data)
  373. })
  374. },
  375. handleOk () {
  376. this.visible = true
  377. this.$refs.table.refresh()
  378. },
  379. onSelectChange (selectedRowKeys, selectedRows) {
  380. this.selectedRowKeys = selectedRowKeys
  381. this.selectedRows = selectedRows
  382. },
  383. resetSearchForm () {
  384. this.queryParam = {
  385. purchaseApplyId: this.purchaseApplyId
  386. }
  387. this.$refs.table.refresh(true)
  388. },
  389. doExport () {
  390. const parameter = {
  391. ...this.queryParam
  392. }
  393. exportPurchaseOrder(parameter).then(file => {
  394. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  395. })
  396. },
  397. handleEnter () {
  398. this.$refs.table.refresh(true)
  399. },
  400. handleCancel (values) {
  401. this.visible = false
  402. this.$emit('ok', values)
  403. }
  404. }
  405. }
  406. </script>