PurchaseOrderPage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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('longyanpurchaseorder-menu-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 || record.status === 0"
  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>=0"
  62. :type="2"
  63. title="是否要删除该条数据?"
  64. @confirm="batchDelete(record.id)">删除</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. checked: true,
  195. width: 100,
  196. dataIndex: 'errorMessage'
  197. },
  198. {
  199. title: '状态',
  200. dataIndex: 'status',
  201. width: '100px',
  202. fixed: 'right',
  203. checked: true,
  204. align: 'center',
  205. scopedSlots: { customRender: 'status' }
  206. },
  207. {
  208. title: '操作',
  209. key: 'action',
  210. width: '200px',
  211. fixed: 'right',
  212. checked: true,
  213. align: 'center',
  214. scopedSlots: { customRender: 'action' }
  215. }
  216. ],
  217. // 下拉框map
  218. typeMap: {},
  219. // 加载数据方法 必须为 Promise 对象
  220. loadData: parameter => {
  221. parameter = {
  222. ...parameter,
  223. ...this.queryParam,
  224. dataScope: {
  225. sortBy: 'desc',
  226. sortName: 'update_time'
  227. }
  228. }
  229. return getPurchaseOrderPage2(Object.assign(parameter, this.queryParam))
  230. .then(res => {
  231. return res.data
  232. })
  233. },
  234. selectedRowKeys: [],
  235. selectedRows: [],
  236. options: {
  237. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  238. rowSelection: {
  239. selectedRowKeys: this.selectedRowKeys
  240. }
  241. },
  242. optionAlertShow: false,
  243. statusMap: {}
  244. }
  245. },
  246. created () {
  247. // 下拉框map
  248. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_TYPE)
  249. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_STATUS)
  250. this.cptcodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_ORDER_PLAN_TYPE)
  251. this.cbustypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LONG_YAN_PURCHASE_BUSINESS_TYPE)
  252. console.log(this.cptcodeMap)
  253. this.tableOption()
  254. },
  255. methods: {
  256. tableOption () {
  257. if (!this.optionAlertShow) {
  258. this.options = {
  259. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  260. rowSelection: {
  261. selectedRowKeys: this.selectedRowKeys,
  262. getCheckboxProps: record => ({
  263. props: {
  264. disabled: false,
  265. name: record.id
  266. }
  267. })
  268. }
  269. }
  270. this.optionAlertShow = true
  271. } else {
  272. this.options = {
  273. alert: false,
  274. rowSelection: null
  275. }
  276. this.optionAlertShow = false
  277. }
  278. },
  279. handleOk () {
  280. this.visible = true
  281. this.$refs.table.refresh()
  282. },
  283. resetSearchForm () {
  284. this.queryParam = {
  285. }
  286. this.$refs.table.refresh(true)
  287. },
  288. batchDelete (id) {
  289. deletePurchaseOrder2({ id }).then(res => {
  290. this.$message.info('删除成功')
  291. this.handleOk()
  292. })
  293. },
  294. batchWaste (record) {
  295. wastePurchaseOrder(record).then(res => {
  296. this.$message.info('废弃成功')
  297. this.handleOk()
  298. })
  299. },
  300. handleEnter () {
  301. this.$refs.table.refresh(true)
  302. },
  303. handleEdit (record) {
  304. getPurchaseOrderInfo(record).then(res => {
  305. this.$refs.baseForm.base(res.data)
  306. })
  307. },
  308. handleView (record) {
  309. getPurchaseOrderInfo(record).then(res => {
  310. this.$refs.detail.base(res.data)
  311. })
  312. },
  313. handlePush (record) {
  314. pushPurchaseOrder(record).then(res => {
  315. this.$message.info('推送成功')
  316. this.handleOk()
  317. this.$refs.table.clearSelected()
  318. })
  319. },
  320. handleViewPurchase (record) {
  321. getPurchaseOrderList({ yongYouId: record.yongYouId, oldOrNew: record.oldOrNew })
  322. .then(res => {
  323. this.$message.info('同步成功')
  324. this.handleOk()
  325. this.$refs.table.clearSelected()
  326. })
  327. }
  328. }
  329. }
  330. </script>