PurchaseApplySelectModal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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="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 { getPurchaseApplyPage, fetchPurchaseApply } from '@/api/purchase/purchase-apply'
  59. export default {
  60. name: 'PurchaseApplySelectModal',
  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: 'billNo'
  108. },
  109. {
  110. title: '总需求计划主键',
  111. dataIndex: 'demandPlanId'
  112. },
  113. {
  114. title: '采购计划ID',
  115. dataIndex: 'purchasePlanId'
  116. },
  117. {
  118. title: '公司ID',
  119. dataIndex: 'companyId'
  120. },
  121. {
  122. title: '公司名称',
  123. dataIndex: 'companyName'
  124. },
  125. {
  126. title: '项目主键',
  127. dataIndex: 'projectId'
  128. },
  129. {
  130. title: '项目名称',
  131. dataIndex: 'projectName'
  132. },
  133. {
  134. title: '类型',
  135. dataIndex: 'type',
  136. customRender: (text, record, index) => {
  137. return this.BaseTool.Object.getField(this.typeMap, text)
  138. } ,
  139. },
  140. {
  141. title: '日期',
  142. dataIndex: 'planDate'
  143. },
  144. {
  145. title: '呈报',
  146. dataIndex: 'reportType',
  147. customRender: (text, record, index) => {
  148. return this.BaseTool.Object.getField(this.reportTypeMap, text)
  149. } ,
  150. },
  151. {
  152. title: '需求日期',
  153. dataIndex: 'demandDate'
  154. },
  155. {
  156. title: '事项',
  157. dataIndex: 'item'
  158. },
  159. {
  160. title: '设备物资综述',
  161. dataIndex: 'summary'
  162. },
  163. {
  164. title: '特殊情况',
  165. dataIndex: 'specialDescription'
  166. },
  167. {
  168. title: '总金额',
  169. dataIndex: 'money',
  170. customRender: (text, record, index) => {
  171. return this.BaseTool.Amount.formatter(text)
  172. } ,
  173. },
  174. {
  175. title: '已付金额',
  176. dataIndex: 'paidMoney',
  177. customRender: (text, record, index) => {
  178. return this.BaseTool.Amount.formatter(text)
  179. } ,
  180. },
  181. {
  182. title: '数量',
  183. dataIndex: 'quantity',
  184. customRender: (text, record, index) => {
  185. return this.BaseTool.Amount.formatter(text)
  186. } ,
  187. },
  188. {
  189. title: '已购数量',
  190. dataIndex: 'boughtQuantity',
  191. customRender: (text, record, index) => {
  192. return this.BaseTool.Amount.formatter(text)
  193. } ,
  194. },
  195. {
  196. title: '已到数量',
  197. dataIndex: 'arrivedQuantity',
  198. customRender: (text, record, index) => {
  199. return this.BaseTool.Amount.formatter(text)
  200. } ,
  201. },
  202. {
  203. title: '未到数量',
  204. dataIndex: 'notArriveQuantity',
  205. customRender: (text, record, index) => {
  206. return this.BaseTool.Amount.formatter(text)
  207. } ,
  208. },
  209. {
  210. title: '总重',
  211. dataIndex: 'totalWeight',
  212. customRender: (text, record, index) => {
  213. return this.BaseTool.Amount.formatter(text)
  214. } ,
  215. },
  216. {
  217. title: '总体积',
  218. dataIndex: 'totalVolume',
  219. customRender: (text, record, index) => {
  220. return this.BaseTool.Amount.formatter(text)
  221. } ,
  222. },
  223. {
  224. title: '拒绝原因',
  225. dataIndex: 'refuseReason'
  226. },
  227. {
  228. title: '申请时间',
  229. dataIndex: 'applyTime'
  230. },
  231. {
  232. title: '审核时间',
  233. dataIndex: 'auditTime'
  234. },
  235. {
  236. title: '状态',
  237. dataIndex: 'status'
  238. },
  239. {
  240. title: '备注',
  241. dataIndex: 'remark'
  242. },
  243. {
  244. title: '删除标志',
  245. dataIndex: 'delFlag'
  246. },
  247. {
  248. title: '创建人名称',
  249. dataIndex: 'createdUserName'
  250. },
  251. {
  252. title: '创建时间',
  253. dataIndex: 'createdTime'
  254. },
  255. {
  256. title: '操作',
  257. key: 'action',
  258. width: '200px',
  259. align: 'center',
  260. scopedSlots: { customRender: 'action' }
  261. }
  262. ],
  263. // 下拉框map
  264. typeMap: {},
  265. reportTypeMap: {},
  266. // 加载数据方法 必须为 Promise 对象
  267. loadData: parameter => {
  268. parameter = {
  269. ...parameter,
  270. ...this.queryParam,
  271. ...this.extraQueryParam,
  272. dataScope: {
  273. sortBy: 'desc',
  274. sortName: 'update_time'
  275. }
  276. }
  277. return getPurchaseApplyPage(Object.assign(parameter, this.queryParam))
  278. .then(res => {
  279. return res.data
  280. })
  281. },
  282. selectedRowKeys: [],
  283. selectedRows: [],
  284. options: {
  285. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  286. rowSelection: {
  287. selectedRowKeys: this.selectedRowKeys,
  288. onChange: this.onSelectChange
  289. }
  290. },
  291. optionAlertShow: false,
  292. isCreated: false
  293. }
  294. },
  295. created () {
  296. // 下拉框map
  297. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_APPLY_TYPE)
  298. this.reportTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_APPLY_REPORT_TYPE)
  299. },
  300. methods: {
  301. tableOption () {
  302. if (!this.optionAlertShow) {
  303. this.options = {
  304. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  305. rowSelection: {
  306. selectedRowKeys: this.selectedRowKeys,
  307. onChange: this.onSelectChange,
  308. type: this.type,
  309. getCheckboxProps: record => ({
  310. props: {
  311. disabled: false,
  312. name: record.id
  313. }
  314. })
  315. },
  316. customRow: (record) => {
  317. return {
  318. on: { // 事件
  319. click: (event) => { // 点击行
  320. // 选择对象
  321. this.mySelect([record.id], [record])
  322. },
  323. dblclick: (event) => {
  324. this.mySelect([record.id], [record])
  325. this.handleSelect()
  326. }
  327. }
  328. }
  329. }
  330. }
  331. this.optionAlertShow = true
  332. } else {
  333. this.options = {
  334. alert: false,
  335. rowSelection: null
  336. }
  337. this.optionAlertShow = false
  338. }
  339. },
  340. handleView (record) {
  341. fetchPurchaseApply({ id: record.id }).then(res => {
  342. const modal = this.$refs.detailModal
  343. modal.base(res.data)
  344. })
  345. },
  346. handleOk () {
  347. this.$refs.table.refresh()
  348. },
  349. onSelectChange (selectedRowKeys, selectedRows) {
  350. this.selectedRowKeys = selectedRowKeys
  351. this.selectedRows = selectedRows
  352. },
  353. resetSearchForm () {
  354. this.queryParam = {
  355. }
  356. this.$refs.table.refresh(true)
  357. },
  358. base (record, queryParam = {}) {
  359. this.visible = true
  360. this.modalTitle = '选择信息'
  361. this.extraQueryParam = queryParam
  362. this.record = record
  363. if (this.isCreated) {
  364. this.$refs.table.clearSelected()
  365. this.options.rowSelection.type = this.type
  366. this.handleOk()
  367. } else {
  368. this.tableOption()
  369. this.isCreated = true
  370. }
  371. },
  372. handleCancel () {
  373. this.visible = false
  374. this.confirmLoading = false
  375. },
  376. handleSelect () {
  377. if (this.selectedRowKeys.length === 0) {
  378. this.$message.warn('请至少选择一项信息')
  379. } else {
  380. this.confirmLoading = true
  381. this.$emit('selected', this.record, this.selectedRowKeys, this.selectedRows)
  382. this.confirmLoading = false
  383. this.visible = false
  384. }
  385. },
  386. mySelect(selectedRowKeys, selectedRows) {
  387. if (this.type === 'radio') {
  388. this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
  389. this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
  390. } else {
  391. let mySelectedRowKeys
  392. let mySelectedRows = this.selectedRows.filter(item => item.id !== selectedRowKeys[0])
  393. if (this.selectedRowKeys.includes(selectedRowKeys[0])) {
  394. mySelectedRowKeys = this.selectedRowKeys.filter(item => item !== selectedRowKeys[0])
  395. } else {
  396. mySelectedRowKeys = [...selectedRowKeys, ...this.selectedRowKeys]
  397. mySelectedRows = [...mySelectedRows, ...selectedRows]
  398. }
  399. this.$refs.table.updateSelect(mySelectedRowKeys, mySelectedRows)
  400. this.$refs.table.rowSelection.onChange(mySelectedRowKeys, mySelectedRows)
  401. }
  402. }
  403. }
  404. }
  405. </script>