PurchaseListSelectModal.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="1000"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-card :bordered="false">
  11. <div class="table-page-search-wrapper">
  12. <a-form layout="inline">
  13. <a-row :gutter="48">
  14. <a-col :md="8" :sm="24">
  15. <a-form-item label="关键字">
  16. <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="8 || 24" :sm="24">
  20. <span class="table-page-search-submitButtons">
  21. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  22. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  23. </span>
  24. </a-col>
  25. </a-row>
  26. </a-form>
  27. </div>
  28. <div class="table-operator" style="margin-bottom: 8px;">
  29. </div>
  30. <s-table
  31. ref="table"
  32. size="default"
  33. rowKey="id"
  34. :columns="columns"
  35. :data="loadData"
  36. :alert="options.alert"
  37. :customRow="options.customRow"
  38. :rowSelection="options.rowSelection"
  39. showPagination="auto"
  40. >
  41. <span slot="action" slot-scope="record1">
  42. <template>
  43. <a @click="handleView(record1)">查看</a>
  44. </template>
  45. </span>
  46. </s-table>
  47. <detail ref="detailModal"/>
  48. </a-card>
  49. <template slot="footer">
  50. <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">取消</a-button>
  51. <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">确定</a-button>
  52. </template>
  53. </a-modal>
  54. </template>
  55. <script>
  56. import { STable, Ellipsis } from '@/components'
  57. import Detail from './Detail'
  58. import { getPurchaseListPage, fetchPurchaseList } from '@/api/purchase/purchase-list'
  59. export default {
  60. name: 'PurchaseListSelectModal',
  61. components: {
  62. STable,
  63. Ellipsis,
  64. Detail
  65. },
  66. props: {
  67. type: {
  68. type: String,
  69. default: 'radio'
  70. },
  71. selectedRowKey: {
  72. type: Array,
  73. default: () => {
  74. return []
  75. }
  76. },
  77. selectedRow: {
  78. type: Array,
  79. default: () => {
  80. return []
  81. }
  82. }
  83. },
  84. data () {
  85. return {
  86. confirmLoading: false,
  87. mdl: {},
  88. modalTitle: null,
  89. visible: false,
  90. record: null,
  91. // 查询参数
  92. queryParam: {
  93. },
  94. extraQueryParam: {
  95. },
  96. // 表头
  97. columns: [
  98. {
  99. title: '序号',
  100. dataIndex: 'index',
  101. customRender: (text, record, index) => {
  102. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  103. }
  104. },
  105. {
  106. title: '总需求计划主键',
  107. dataIndex: 'demandPlanId'
  108. },
  109. {
  110. title: '采购计划主键',
  111. dataIndex: 'purchasePlanId'
  112. },
  113. {
  114. title: '采购申请ID',
  115. dataIndex: 'purchaseApplyId'
  116. },
  117. {
  118. title: '采购单ID',
  119. dataIndex: 'purchaseOrderId'
  120. },
  121. {
  122. title: '编号',
  123. dataIndex: 'no'
  124. },
  125. {
  126. title: '类别',
  127. dataIndex: 'type'
  128. },
  129. {
  130. title: '名称',
  131. dataIndex: 'name'
  132. },
  133. {
  134. title: '规格',
  135. dataIndex: 'specs'
  136. },
  137. {
  138. title: '单位',
  139. dataIndex: 'unit',
  140. customRender: (text, record, index) => {
  141. return this.BaseTool.Object.getField(this.unitMap, text)
  142. } ,
  143. },
  144. {
  145. title: '单价',
  146. dataIndex: 'price',
  147. customRender: (text, record, index) => {
  148. return this.BaseTool.Amount.formatter(text)
  149. } ,
  150. },
  151. {
  152. title: '综合单价',
  153. dataIndex: 'integratedPrice',
  154. customRender: (text, record, index) => {
  155. return this.BaseTool.Amount.formatter(text)
  156. } ,
  157. },
  158. {
  159. title: '数量',
  160. dataIndex: 'quantity',
  161. customRender: (text, record, index) => {
  162. return this.BaseTool.Amount.formatter(text)
  163. } ,
  164. },
  165. {
  166. title: '总价',
  167. dataIndex: 'totalMoney',
  168. customRender: (text, record, index) => {
  169. return this.BaseTool.Amount.formatter(text)
  170. } ,
  171. },
  172. {
  173. title: '税率',
  174. dataIndex: 'taxRate',
  175. customRender: (text, record, index) => {
  176. return this.BaseTool.Amount.formatter(text)
  177. } ,
  178. },
  179. {
  180. title: '税额',
  181. dataIndex: 'taxMoney',
  182. customRender: (text, record, index) => {
  183. return this.BaseTool.Amount.formatter(text)
  184. } ,
  185. },
  186. {
  187. title: '品牌',
  188. dataIndex: 'brand'
  189. },
  190. {
  191. title: '适用车型',
  192. dataIndex: 'suitableModel'
  193. },
  194. {
  195. title: '车架号',
  196. dataIndex: 'vin'
  197. },
  198. {
  199. title: '发动机号',
  200. dataIndex: 'engineNum'
  201. },
  202. {
  203. title: '折扣',
  204. dataIndex: 'discount',
  205. customRender: (text, record, index) => {
  206. return this.BaseTool.Amount.formatter(text)
  207. } ,
  208. },
  209. {
  210. title: '已购数量',
  211. dataIndex: 'boughtQuantity',
  212. customRender: (text, record, index) => {
  213. return this.BaseTool.Amount.formatter(text)
  214. } ,
  215. },
  216. {
  217. title: '已到数量',
  218. dataIndex: 'arrivedQuantity',
  219. customRender: (text, record, index) => {
  220. return this.BaseTool.Amount.formatter(text)
  221. } ,
  222. },
  223. {
  224. title: '未到数量',
  225. dataIndex: 'notArriveQuantity',
  226. customRender: (text, record, index) => {
  227. return this.BaseTool.Amount.formatter(text)
  228. } ,
  229. },
  230. {
  231. title: '已用金额',
  232. dataIndex: 'usedMoney',
  233. customRender: (text, record, index) => {
  234. return this.BaseTool.Amount.formatter(text)
  235. } ,
  236. },
  237. {
  238. title: '已发运数量',
  239. dataIndex: 'dispatchedQuantity',
  240. customRender: (text, record, index) => {
  241. return this.BaseTool.Amount.formatter(text)
  242. } ,
  243. },
  244. {
  245. title: '未发运数量',
  246. dataIndex: 'notDispatchQuantity',
  247. customRender: (text, record, index) => {
  248. return this.BaseTool.Amount.formatter(text)
  249. } ,
  250. },
  251. {
  252. title: '产地',
  253. dataIndex: 'producePlace'
  254. },
  255. {
  256. title: '重量',
  257. dataIndex: 'weight',
  258. customRender: (text, record, index) => {
  259. return this.BaseTool.Amount.formatter(text)
  260. } ,
  261. },
  262. {
  263. title: '体积',
  264. dataIndex: 'volume',
  265. customRender: (text, record, index) => {
  266. return this.BaseTool.Amount.formatter(text)
  267. } ,
  268. },
  269. {
  270. title: '外形尺寸',
  271. dataIndex: 'dimension'
  272. },
  273. {
  274. title: '供应商ID',
  275. dataIndex: 'supplierId'
  276. },
  277. {
  278. title: '供应商名称',
  279. dataIndex: 'supplierName'
  280. },
  281. {
  282. title: '供应商单价',
  283. dataIndex: 'supplyPrice',
  284. customRender: (text, record, index) => {
  285. return this.BaseTool.Amount.formatter(text)
  286. } ,
  287. },
  288. {
  289. title: '供应商总额',
  290. dataIndex: 'supplyTotalMoney',
  291. customRender: (text, record, index) => {
  292. return this.BaseTool.Amount.formatter(text)
  293. } ,
  294. },
  295. {
  296. title: '合同ID',
  297. dataIndex: 'contractId'
  298. },
  299. {
  300. title: '备注',
  301. dataIndex: 'remark'
  302. },
  303. {
  304. title: '状态',
  305. dataIndex: 'status',
  306. customRender: (text, record, index) => {
  307. return this.BaseTool.Object.getField(this.statusMap, text)
  308. } ,
  309. },
  310. {
  311. title: '删除标志',
  312. dataIndex: 'delFlag'
  313. },
  314. {
  315. title: '创建人名称',
  316. dataIndex: 'createdUserName'
  317. },
  318. {
  319. title: '创建时间',
  320. dataIndex: 'createdTime'
  321. },
  322. {
  323. title: '操作',
  324. key: 'action',
  325. width: '200px',
  326. align: 'center',
  327. scopedSlots: { customRender: 'action' }
  328. }
  329. ],
  330. // 下拉框map
  331. unitMap: {},
  332. statusMap: {},
  333. // 加载数据方法 必须为 Promise 对象
  334. loadData: parameter => {
  335. parameter = {
  336. ...parameter,
  337. ...this.queryParam,
  338. ...this.extraQueryParam,
  339. dataScope: {
  340. sortBy: 'desc',
  341. sortName: 'update_time'
  342. }
  343. }
  344. return getPurchaseListPage(Object.assign(parameter, this.queryParam))
  345. .then(res => {
  346. return res.data
  347. })
  348. },
  349. selectedRowKeys: [],
  350. selectedRows: [],
  351. options: {
  352. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  353. rowSelection: {
  354. selectedRowKeys: this.selectedRowKeys,
  355. onChange: this.onSelectChange
  356. }
  357. },
  358. optionAlertShow: false,
  359. isCreated: false
  360. }
  361. },
  362. created () {
  363. // 下拉框map
  364. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_LIST_UNIT)
  365. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_LIST_STATUS)
  366. },
  367. methods: {
  368. tableOption () {
  369. if (!this.optionAlertShow) {
  370. this.options = {
  371. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  372. rowSelection: {
  373. selectedRowKeys: this.selectedRowKeys,
  374. onChange: this.onSelectChange,
  375. type: this.type,
  376. getCheckboxProps: record => ({
  377. props: {
  378. disabled: false,
  379. name: record.id
  380. }
  381. })
  382. },
  383. customRow: (record) => {
  384. return {
  385. on: { // 事件
  386. click: (event) => { // 点击行
  387. // 选择对象
  388. this.mySelect([record.id], [record])
  389. },
  390. dblclick: (event) => {
  391. this.mySelect([record.id], [record])
  392. this.handleSelect()
  393. }
  394. }
  395. }
  396. }
  397. }
  398. this.optionAlertShow = true
  399. } else {
  400. this.options = {
  401. alert: false,
  402. rowSelection: null
  403. }
  404. this.optionAlertShow = false
  405. }
  406. },
  407. handleView (record) {
  408. fetchPurchaseList({ id: record.id }).then(res => {
  409. const modal = this.$refs.detailModal
  410. modal.base(res.data)
  411. })
  412. },
  413. handleOk () {
  414. this.$refs.table.refresh()
  415. },
  416. onSelectChange (selectedRowKeys, selectedRows) {
  417. this.selectedRowKeys = selectedRowKeys
  418. this.selectedRows = selectedRows
  419. },
  420. resetSearchForm () {
  421. this.queryParam = {
  422. }
  423. this.$refs.table.refresh(true)
  424. },
  425. base (record, queryParam = {}) {
  426. this.visible = true
  427. this.modalTitle = '选择信息'
  428. this.extraQueryParam = queryParam
  429. this.record = record
  430. if (this.isCreated) {
  431. this.$refs.table.clearSelected()
  432. this.options.rowSelection.type = this.type
  433. this.handleOk()
  434. } else {
  435. this.tableOption()
  436. this.isCreated = true
  437. }
  438. },
  439. handleCancel () {
  440. this.visible = false
  441. this.confirmLoading = false
  442. },
  443. handleSelect () {
  444. if (this.selectedRowKeys.length === 0) {
  445. this.$message.warn('请至少选择一项信息')
  446. } else {
  447. this.confirmLoading = true
  448. this.$emit('selected', this.record, this.selectedRowKeys, this.selectedRows)
  449. this.confirmLoading = false
  450. this.visible = false
  451. }
  452. },
  453. mySelect(selectedRowKeys, selectedRows) {
  454. if (this.type === 'radio') {
  455. this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
  456. this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
  457. } else {
  458. let mySelectedRowKeys
  459. let mySelectedRows = this.selectedRows.filter(item => item.id !== selectedRowKeys[0])
  460. if (this.selectedRowKeys.includes(selectedRowKeys[0])) {
  461. mySelectedRowKeys = this.selectedRowKeys.filter(item => item !== selectedRowKeys[0])
  462. } else {
  463. mySelectedRowKeys = [...selectedRowKeys, ...this.selectedRowKeys]
  464. mySelectedRows = [...mySelectedRows, ...selectedRows]
  465. }
  466. this.$refs.table.updateSelect(mySelectedRowKeys, mySelectedRows)
  467. this.$refs.table.rowSelection.onChange(mySelectedRowKeys, mySelectedRows)
  468. }
  469. }
  470. }
  471. }
  472. </script>