PurchaseOrderPage.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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-orders-add')" type="primary" icon="plus" @click="$refs.baseForm.base()">采购计划</a-button>
  23. <a-button v-if="$auth('purchase-purchase-orders-add')" style="margin-left: 8px" type="primary" icon="plus" @click="$refs.addSpareForm.base()">新增物料</a-button>
  24. <!-- <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('purchase-purchase-orders-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="default"
  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. <a @click="handleView(record)">查看</a>
  48. <operation-button
  49. v-if="record.status===1"
  50. @click="handleEdit(record)"
  51. >修改</operation-button>
  52. <operation-button
  53. v-if=" record.status===1"
  54. @click="handlePush(record)"
  55. >推送</operation-button>
  56. <operation-button
  57. v-if=" record.status>=3"
  58. :type="2"
  59. title="是否要删除该条数据?"
  60. @confirm="batchDelete(record.yongYouId)">删除</operation-button>
  61. <operation-button
  62. v-if=" record.status==1||record.status==2"
  63. :type="2"
  64. title="是否要废弃该条数据?"
  65. @confirm="batchWaste(record)">废弃</operation-button>
  66. </span>
  67. <template #status="text">
  68. <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.LONG_YAN_PURCHASE_ORDER_STATUS[text]"/>
  69. </template>
  70. </s-table>
  71. </div>
  72. <BaseForm ref="baseForm" @ok="handleOk"/>
  73. <Detail ref="detail" @ok="handleOk"/>
  74. <AddSpareForm ref="addSpareForm" />
  75. </a-card>
  76. </template>
  77. <script>
  78. import { STable, Ellipsis } from '@/components'
  79. import { getPurchaseOrderPage2, deletePurchaseOrder2, getPurchaseOrderInfo, pushPurchaseOrder, wastePurchaseOrder } from '@/api/purchase/purchase-order'
  80. import BaseForm from './modules/BaseForm.vue'
  81. import Detail from './modules/Detail.vue'
  82. import AddSpareForm from '@/views/store/sparestore/modules/AddSpareForm'
  83. export default {
  84. name: 'PurchaseOrderList',
  85. components: {
  86. STable,
  87. Ellipsis,
  88. BaseForm,
  89. AddSpareForm,
  90. Detail
  91. },
  92. data () {
  93. return {
  94. // 查询参数
  95. queryParam: {
  96. },
  97. visible: true,
  98. user: this.$store.getters.userInfo,
  99. dollarExchangeRate: this.$store.getters.rmbRate,
  100. cptcodeMap: {},
  101. cbustypeMap: {},
  102. // 表头
  103. columns: [
  104. {
  105. title: '序号',
  106. dataIndex: 'index',
  107. checked: true,
  108. width: 70,
  109. customRender: (text, record, index) => {
  110. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  111. }
  112. },
  113. {
  114. title: '计划名称',
  115. dataIndex: 'orderName',
  116. checked: true,
  117. width: 150
  118. },
  119. {
  120. title: '计划类型',
  121. dataIndex: 'type',
  122. checked: true,
  123. width: 100,
  124. customRender: (text, record, index) => {
  125. return this.BaseTool.Table.getMapText(this.typeMap, text)
  126. }
  127. },
  128. {
  129. title: '采购类型',
  130. dataIndex: 'cptcode',
  131. checked: true,
  132. width: 130,
  133. customRender: (text, record, index) => {
  134. return this.BaseTool.Table.getMapText(this.cptcodeMap, text)
  135. }
  136. },
  137. {
  138. title: '业务类型',
  139. dataIndex: 'cbustype',
  140. checked: true,
  141. width: 150,
  142. customRender: (text, record, index) => {
  143. return this.BaseTool.Table.getMapText(this.cbustypeMap, text)
  144. }
  145. },
  146. {
  147. title: '关联设备',
  148. dataIndex: 'positionNo',
  149. checked: true,
  150. width: 150
  151. },
  152. {
  153. title: '采购数量',
  154. dataIndex: 'totalNum',
  155. checked: true,
  156. width: 150
  157. },
  158. {
  159. title: '申请人',
  160. dataIndex: 'createdUserName',
  161. checked: true,
  162. width: 150
  163. },
  164. {
  165. title: '需求日期',
  166. dataIndex: 'needDate',
  167. checked: true,
  168. width: 150
  169. },
  170. {
  171. title: '计划到货日期',
  172. dataIndex: 'planGetDate',
  173. checked: true,
  174. width: 150
  175. },
  176. {
  177. title: '申请时间',
  178. dataIndex: 'updateTime',
  179. checked: true,
  180. width: 150
  181. },
  182. {
  183. title: '计划备注',
  184. checked: true,
  185. width: 100,
  186. dataIndex: 'remark'
  187. },
  188. {
  189. title: '状态',
  190. dataIndex: 'status',
  191. width: '100px',
  192. fixed: 'right',
  193. checked: true,
  194. align: 'center',
  195. scopedSlots: { customRender: 'status' }
  196. },
  197. {
  198. title: '操作',
  199. key: 'action',
  200. width: '200px',
  201. fixed: 'right',
  202. checked: true,
  203. align: 'center',
  204. scopedSlots: { customRender: 'action' }
  205. }
  206. ],
  207. // 下拉框map
  208. typeMap: {},
  209. // 加载数据方法 必须为 Promise 对象
  210. loadData: parameter => {
  211. parameter = {
  212. ...parameter,
  213. ...this.queryParam,
  214. dataScope: {
  215. sortBy: 'desc',
  216. sortName: 'update_time'
  217. }
  218. }
  219. return getPurchaseOrderPage2(Object.assign(parameter, this.queryParam))
  220. .then(res => {
  221. return res.data
  222. })
  223. },
  224. selectedRowKeys: [],
  225. selectedRows: [],
  226. options: {
  227. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  228. rowSelection: {
  229. selectedRowKeys: this.selectedRowKeys
  230. }
  231. },
  232. optionAlertShow: false,
  233. statusMap: {}
  234. }
  235. },
  236. created () {
  237. // 下拉框map
  238. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
  239. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_STATUS)
  240. this.cptcodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_PLAN_TYPE)
  241. this.cbustypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_BUSINESS_TYPE)
  242. console.log(this.cptcodeMap)
  243. this.tableOption()
  244. },
  245. methods: {
  246. tableOption () {
  247. if (!this.optionAlertShow) {
  248. this.options = {
  249. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  250. rowSelection: {
  251. selectedRowKeys: this.selectedRowKeys,
  252. getCheckboxProps: record => ({
  253. props: {
  254. disabled: false,
  255. name: record.id
  256. }
  257. })
  258. }
  259. }
  260. this.optionAlertShow = true
  261. } else {
  262. this.options = {
  263. alert: false,
  264. rowSelection: null
  265. }
  266. this.optionAlertShow = false
  267. }
  268. },
  269. handleOk () {
  270. this.visible = true
  271. this.$refs.table.refresh()
  272. },
  273. resetSearchForm () {
  274. this.queryParam = {
  275. }
  276. this.$refs.table.refresh(true)
  277. },
  278. batchDelete (id) {
  279. deletePurchaseOrder2({ id }).then(res => {
  280. this.$message.info('删除成功')
  281. this.handleOk()
  282. })
  283. },
  284. batchWaste (record) {
  285. wastePurchaseOrder(record).then(res => {
  286. this.$message.info('废弃成功')
  287. this.handleOk()
  288. })
  289. },
  290. handleEnter () {
  291. this.$refs.table.refresh(true)
  292. },
  293. handleEdit (record) {
  294. getPurchaseOrderInfo(record).then(res => {
  295. this.$refs.baseForm.base(res.data)
  296. })
  297. },
  298. handleView (record) {
  299. getPurchaseOrderInfo(record).then(res => {
  300. this.$refs.detail.base(res.data)
  301. })
  302. },
  303. handlePush (record) {
  304. pushPurchaseOrder(record).then(res => {
  305. this.$message.info('推送成功')
  306. this.handleOk()
  307. this.$refs.table.clearSelected()
  308. })
  309. }
  310. }
  311. }
  312. </script>