PurchaseOrderPage.vue 9.9 KB

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