PurchaseContractMainList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8 || 24" :sm="24">
  12. <span class="table-page-search-submitButtons">
  13. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  14. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  15. </span>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="table-operator" style="margin-bottom: 8px;">
  21. <a-button v-if="$auth('purchase-purchase-contract-main-lists-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  22. <a-button style="margin-left: 8px" v-if="$auth('purchase-purchase-contract-main-lists-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  23. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-contract-main-lists-del')">
  24. <a-menu slot="overlay">
  25. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  26. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  27. </a-popconfirm>
  28. </a-menu>
  29. <a-button style="margin-left: 8px">
  30. 批量操作 <a-icon type="down" />
  31. </a-button>
  32. </a-dropdown>
  33. </div>
  34. <s-table
  35. ref="table"
  36. size="small"
  37. rowKey="id"
  38. :columns="columns"
  39. :data="loadData"
  40. :alert="options.alert"
  41. :rowSelection="options.rowSelection"
  42. showPagination="auto"
  43. >
  44. <span slot="action" slot-scope="record">
  45. <template>
  46. <a @click="handleView(record)">查看</a>
  47. <operation-button
  48. v-if="$auth('purchase-purchase-contract-main-lists-edit')" @click="handleEdit(record)"
  49. >修改</operation-button>
  50. <operation-button
  51. v-if="$auth('purchase-purchase-contract-main-lists-del')"
  52. :type="2"
  53. title="是否要删除该条数据?"
  54. @confirm="batchDelete(record.id)">删除</operation-button>
  55. </template>
  56. </span>
  57. </s-table>
  58. <base-form ref="baseModal" @ok="handleOk"/>
  59. <detail ref="detailModal"/>
  60. </a-card>
  61. </template>
  62. <script>
  63. import { STable, Ellipsis } from '@/components'
  64. import BaseForm from './modules/BaseForm'
  65. import Detail from './modules/Detail'
  66. import { getPurchaseContractMainListPage, deletePurchaseContractMainLists, fetchPurchaseContractMainList, exportPurchaseContractMainList } from '@/api/purchase/purchase-contract-main-list'
  67. export default {
  68. name: 'PurchaseContractMainListList',
  69. components: {
  70. STable,
  71. Ellipsis,
  72. BaseForm,
  73. Detail
  74. },
  75. data () {
  76. return {
  77. // 查询参数
  78. queryParam: {
  79. },
  80. // 表头
  81. columns: [
  82. {
  83. title: '序号',
  84. dataIndex: 'index',
  85. customRender: (text, record, index) => {
  86. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  87. }
  88. },
  89. {
  90. title: '总需求计划主键',
  91. dataIndex: 'demandPlanId'
  92. },
  93. {
  94. title: '采购计划主键',
  95. dataIndex: 'purchasePlanId'
  96. },
  97. {
  98. title: '采购申请ID',
  99. dataIndex: 'purchaseApplyId'
  100. },
  101. {
  102. title: '采购单ID',
  103. dataIndex: 'purchaseOrderId'
  104. },
  105. {
  106. title: '发运单ID',
  107. dataIndex: 'dispatchOrderId'
  108. },
  109. {
  110. title: '名称',
  111. dataIndex: 'name'
  112. },
  113. {
  114. title: '型号',
  115. dataIndex: 'model'
  116. },
  117. {
  118. title: '整机编号',
  119. dataIndex: 'machineNo'
  120. },
  121. {
  122. title: '发动机型号',
  123. dataIndex: 'engineModel'
  124. },
  125. {
  126. title: '发动机编号',
  127. dataIndex: 'engineNo'
  128. },
  129. {
  130. title: '数量',
  131. dataIndex: 'quantity',
  132. customRender: (text, record, index) => {
  133. return this.BaseTool.Amount.formatter(text)
  134. } ,
  135. },
  136. {
  137. title: '单位',
  138. dataIndex: 'unit',
  139. customRender: (text, record, index) => {
  140. return this.BaseTool.Table.getMapText(this.unitMap, text)
  141. } ,
  142. },
  143. {
  144. title: '单价',
  145. dataIndex: 'price',
  146. customRender: (text, record, index) => {
  147. return this.BaseTool.Amount.formatter(text)
  148. } ,
  149. },
  150. {
  151. title: '总价',
  152. dataIndex: 'totalMoney',
  153. customRender: (text, record, index) => {
  154. return this.BaseTool.Amount.formatter(text)
  155. } ,
  156. },
  157. {
  158. title: '备注',
  159. dataIndex: 'remark'
  160. },
  161. {
  162. title: '删除标志',
  163. dataIndex: 'delFlag'
  164. },
  165. {
  166. title: '创建人名称',
  167. dataIndex: 'createdUserName'
  168. },
  169. {
  170. title: '创建时间',
  171. dataIndex: 'createdTime'
  172. },
  173. {
  174. title: '操作',
  175. key: 'action',
  176. width: '200px',
  177. align: 'center',
  178. scopedSlots: { customRender: 'action' }
  179. }
  180. ],
  181. // 下拉框map
  182. unitMap: {},
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. parameter = {
  186. ...parameter,
  187. ...this.queryParam,
  188. dataScope: {
  189. sortBy: 'desc',
  190. sortName: 'update_time'
  191. }
  192. }
  193. return getPurchaseContractMainListPage(Object.assign(parameter, this.queryParam))
  194. .then(res => {
  195. return res.data
  196. })
  197. },
  198. selectedRowKeys: [],
  199. selectedRows: [],
  200. options: {
  201. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  202. rowSelection: {
  203. selectedRowKeys: this.selectedRowKeys,
  204. onChange: this.onSelectChange
  205. }
  206. },
  207. optionAlertShow: false
  208. }
  209. },
  210. created () {
  211. // 下拉框map
  212. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PURCHASE_CONTRACT_MAIN_LIST_UNIT)
  213. this.tableOption()
  214. },
  215. methods: {
  216. tableOption () {
  217. if (!this.optionAlertShow) {
  218. this.options = {
  219. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  220. rowSelection: {
  221. selectedRowKeys: this.selectedRowKeys,
  222. onChange: this.onSelectChange,
  223. getCheckboxProps: record => ({
  224. props: {
  225. disabled: false,
  226. name: record.id
  227. }
  228. })
  229. }
  230. }
  231. this.optionAlertShow = true
  232. } else {
  233. this.options = {
  234. alert: false,
  235. rowSelection: null
  236. }
  237. this.optionAlertShow = false
  238. }
  239. },
  240. batchDelete (id) {
  241. let ids = []
  242. if (this.BaseTool.String.isBlank(id)) {
  243. const length = this.selectedRows.length
  244. if (length === 0) {
  245. this.$message.info('请选择要删除的记录')
  246. return
  247. }
  248. ids = this.selectedRows.map(item => item.id)
  249. } else {
  250. ids = [id]
  251. }
  252. deletePurchaseContractMainLists(ids).then(res => {
  253. this.$message.info('删除成功')
  254. this.handleOk()
  255. this.$refs.table.clearSelected()
  256. })
  257. },
  258. handleEdit (record) {
  259. fetchPurchaseContractMainList({ id: record.id }).then(res => {
  260. const modal = this.$refs.baseModal
  261. modal.base(res.data)
  262. })
  263. },
  264. handleView (record) {
  265. fetchPurchaseContractMainList({ id: record.id }).then(res => {
  266. const modal = this.$refs.detailModal
  267. modal.base(res.data)
  268. })
  269. },
  270. handleOk () {
  271. this.$refs.table.refresh()
  272. },
  273. onSelectChange (selectedRowKeys, selectedRows) {
  274. this.selectedRowKeys = selectedRowKeys
  275. this.selectedRows = selectedRows
  276. },
  277. resetSearchForm () {
  278. this.queryParam = {
  279. }
  280. this.$refs.table.refresh(true)
  281. },
  282. doExport () {
  283. const parameter = {
  284. ...this.queryParam
  285. }
  286. exportPurchaseContractMainList(parameter).then(file => {
  287. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  288. })
  289. },
  290. handleEnter () {
  291. this.$refs.table.refresh(true)
  292. }
  293. }
  294. }
  295. </script>