list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <a-card size="small" :bordered="false" class="purchaseOrderList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="采购单号">
  15. <a-input id="purchaseOrderList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="供应商" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  20. <a-select
  21. id="purchaseOrderList-purchaseTargetSn"
  22. placeholder="请选择供应商"
  23. allowClear
  24. v-model="queryParam.purchaseTargetSn"
  25. :showSearch="true"
  26. option-filter-prop="children"
  27. :filter-option="filterOption"
  28. @change="tragetTypeChange">
  29. <a-select-option v-for="item in supplierList" :pyCode="item.pyCode" :key="item.purchaseTargetSn" :value="item.purchaseTargetSn">{{ item.purchaseTargetName }}</a-select-option>
  30. </a-select>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24" v-show="advanced">
  34. <a-form-item label="业务状态">
  35. <a-select id="purchaseOrderList-billStatus" allowClear v-model="queryParam.billStatus" placeholder="请选择业务状态">
  36. <a-select-option value="">全部</a-select-option>
  37. <a-select-option value="WAIT_SUBMIT">待提交</a-select-option>
  38. <a-select-option value="SUBMIT">已提交</a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24" v-show="advanced">
  43. <a-form-item label="财务状态">
  44. <v-select
  45. v-model="queryParam.financialStatus"
  46. ref="financialStatus"
  47. id="purchaseOrderList-financialStatus"
  48. code="FINANCIAL_PAY_STATUS"
  49. placeholder="请选择财务状态"
  50. allowClear></v-select>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24" v-show="advanced">
  54. <a-form-item label="单据来源">
  55. <v-select
  56. v-model="queryParam.purchaseBillSource"
  57. ref="purchaseBillSource"
  58. id="purchaseOrderList-purchaseBillSource"
  59. code="PURCHASE_SOURCE"
  60. placeholder="请选择单据来源"
  61. allowClear></v-select>
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24" v-show="advanced">
  65. <a-form-item label="促销单">
  66. <v-select
  67. v-model="queryParam.promotionFlag"
  68. ref="promotionFlag"
  69. id="purchaseOrderList-promotionFlag"
  70. code="FLAG"
  71. placeholder="请选择是否促销单"
  72. allowClear></v-select>
  73. </a-form-item>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <span class="table-page-search-submitButtons">
  77. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOrderList-refresh">查询</a-button>
  78. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="purchaseOrderList-reset">重置</a-button>
  79. <a @click="advanced=!advanced" style="margin-left: 8px">
  80. {{ advanced ? '收起' : '展开' }}
  81. <a-icon :type="advanced ? 'up' : 'down'"/>
  82. </a>
  83. </span>
  84. </a-col>
  85. </a-row>
  86. </a-form>
  87. </div>
  88. <!-- 操作按钮 -->
  89. <div class="table-operator">
  90. <a-button id="purchaseOrderList-add" type="primary" v-if="$hasPermissions('B_purchaseNew')&&($hasPermissions('B_SUPPLIER_SJ')||$hasPermissions('B_SUPPLIER_ZB'))" class="button-error" @click="handleAdd">新增</a-button>
  91. </div>
  92. <!-- alert -->
  93. <a-alert type="info" style="margin-bottom:10px">
  94. <div slot="message">
  95. 共 <strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong> 条记录,
  96. 采购数量合计 <strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong> ,
  97. 采购金额合计 <strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount,2) : '--' }}</strong>,
  98. 审核金额合计 <strong>{{ totalData&&(totalData.totalAuthAmount || totalData.totalAuthAmount==0) ? toThousands(totalData.totalAuthAmount,2) : '--' }}</strong>
  99. </div>
  100. </a-alert>
  101. <!-- 列表 -->
  102. <s-table
  103. class="sTable fixPagination"
  104. ref="table"
  105. :style="{ height: tableHeight+84.5+'px' }"
  106. size="small"
  107. :rowKey="(record) => record.id"
  108. :columns="columns"
  109. :data="loadData"
  110. :scroll="{ y: tableHeight }"
  111. :defaultLoadData="false"
  112. bordered>
  113. <!-- 采购单号 -->
  114. <template slot="purchaseBillNo" slot-scope="text, record">
  115. <span class="table-td-link" v-if="$hasPermissions('B_purchaseDetail')" @click="handleDetail(record)">{{ record.purchaseBillNo }}</span>
  116. <span v-else>{{ record.purchaseBillNo }}</span>
  117. <a-badge v-if="record.promotionFlag && record.promotionFlag==1" count="促" :number-style="{ backgroundColor: '#52c41a', zoom:'80%',marginLeft:'5px' }"></a-badge>
  118. <a-badge count="改" v-if="record.billStatus=='HQ_CHANGE'||record.billStatus=='SUPERIOR_CHANGE'" :number-style="{ zoom:'80%',marginLeft:'5px' }"></a-badge>
  119. </template>
  120. <!-- 审核 -->
  121. <template slot="audit" slot-scope="text, record">
  122. <stateIcon :title="record.billStatusDictValue" v-if="record.billStatus!='AUDIT_REJECT'" :state="record.billStatus == 'WAIT_PUT_WAREHOUSE'||record.billStatus=='AUDIT_PASS'||record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  123. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  124. </template>
  125. <!-- 付款 -->
  126. <template slot="financial" slot-scope="text, record">
  127. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  128. </template>
  129. <!-- 入库 -->
  130. <template slot="waitOut" slot-scope="text, record">
  131. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  132. </template>
  133. <!-- 操作 -->
  134. <template slot="action" slot-scope="text, record">
  135. <a-button
  136. size="small"
  137. type="link"
  138. class="button-primary"
  139. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')"
  140. @click="handleEdit(record)"
  141. >编辑</a-button>
  142. <a-button
  143. size="small"
  144. type="link"
  145. class="button-error"
  146. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') &&$hasPermissions('B_purchaseDel')"
  147. @click="handleDel(record)"
  148. >删除</a-button>
  149. <span v-if="!((record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')) && !((record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') &&$hasPermissions('B_purchaseDel'))">--</span>
  150. </template>
  151. </s-table>
  152. </a-spin>
  153. <!-- 选择基本信息弹框 -->
  154. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  155. </a-card>
  156. </template>
  157. <script>
  158. import { commonMixin } from '@/utils/mixin'
  159. import { STable, VSelect } from '@/components'
  160. import rangeDate from '@/views/common/rangeDate.vue'
  161. import basicInfoModal from './basicInfoModal.vue'
  162. import stateIcon from '@/views/common/stateIcon'
  163. import getDate from '@/libs/getDate.js'
  164. import { purchaseList, purchaseDel, purchaseCount } from '@/api/purchase'
  165. import { queryReturnSupplierList } from '@/api/purchaseReturn'
  166. export default {
  167. name: 'PurchaseList',
  168. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon },
  169. mixins: [commonMixin],
  170. data () {
  171. const _this = this
  172. return {
  173. spinning: false,
  174. advanced: true, // 高级搜索 展开/关闭
  175. disabled: false, // 查询、重置按钮是否可操作
  176. openModal: false, // 基本信息弹框是否显示
  177. supplierList: [],
  178. tableHeight: 0,
  179. time: [
  180. getDate.getCurrMonthDays().starttime,
  181. getDate.getCurrMonthDays().endtime
  182. ],
  183. // 查询参数
  184. queryParam: {
  185. purchaseBillNo: '',
  186. purchaseTargetSn: undefined,
  187. purchaseTargetType: undefined,
  188. billStatus: undefined,
  189. financialStatus: undefined,
  190. purchaseBillSource: undefined,
  191. promotionFlag: undefined,
  192. beginDate: getDate.getCurrMonthDays().starttime,
  193. endDate: getDate.getCurrMonthDays().endtime
  194. },
  195. totalData: {
  196. totalRecord: 0,
  197. totalCategory: 0,
  198. totalQty: 0,
  199. totalAmount: 0
  200. },
  201. // 表头
  202. columns: [
  203. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  204. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: '13%', align: 'center' },
  205. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  206. { title: '供应商', dataIndex: 'purchaseTargetName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  207. { title: '产品款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  208. { title: '采购数量', dataIndex: 'totalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  209. { title: '采购金额', dataIndex: 'discountedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  210. { title: '审核数量', dataIndex: 'totalPushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  211. { title: '审核金额', dataIndex: 'totalPushedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  212. { title: '已取消数量', dataIndex: 'totalCancelQty', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  213. { title: '采购状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  214. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  215. { title: '入库', scopedSlots: { customRender: 'waitOut' }, width: '3%', align: 'center' },
  216. { title: '付款', scopedSlots: { customRender: 'financial' }, width: '3%', align: 'center' },
  217. // { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  219. ],
  220. // 加载数据方法 必须为 Promise 对象
  221. loadData: parameter => {
  222. this.disabled = true
  223. this.spinning = true
  224. const params = Object.assign(parameter, this.queryParam)
  225. if (!params.billStatus) {
  226. params.billStatus = undefined
  227. }
  228. // 获取统计数据
  229. this.getTotalData(params)
  230. return purchaseList(params).then(res => {
  231. let data
  232. if (res.status == 200) {
  233. data = res.data
  234. const no = (data.pageNo - 1) * data.pageSize
  235. for (var i = 0; i < data.list.length; i++) {
  236. data.list[i].no = no + i + 1
  237. }
  238. this.disabled = false
  239. }
  240. this.spinning = false
  241. return data
  242. })
  243. }
  244. }
  245. },
  246. methods: {
  247. getTotalData (params) {
  248. purchaseCount(params).then(res => {
  249. this.totalData = res.data || null
  250. })
  251. },
  252. // 供应商change
  253. tragetTypeChange (val) {
  254. const ind = this.supplierList.findIndex(item => item.purchaseTargetSn == val)
  255. if (ind != -1) {
  256. this.queryParam.purchaseTargetType = this.supplierList[ind].purchaseTargetType
  257. } else {
  258. this.queryParam.purchaseTargetSn = undefined
  259. this.queryParam.purchaseTargetType = undefined
  260. }
  261. },
  262. // 时间 change
  263. dateChange (date) {
  264. this.queryParam.beginDate = date[0]
  265. this.queryParam.endDate = date[1]
  266. },
  267. // 新增
  268. handleAdd () {
  269. this.openModal = true
  270. },
  271. // 基本信息 保存
  272. handleOk (row) {
  273. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  274. },
  275. // 编辑
  276. handleEdit (row) {
  277. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  278. },
  279. // 详情
  280. handleDetail (row) {
  281. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  282. },
  283. // 删除
  284. handleDel (row) {
  285. const _this = this
  286. this.$confirm({
  287. title: '提示',
  288. content: '删除后不可恢复,确定要进行删除吗?',
  289. centered: true,
  290. onOk () {
  291. _this.spinning = true
  292. purchaseDel({
  293. id: row.id
  294. }).then(res => {
  295. if (res.status == 200) {
  296. _this.$message.success(res.message)
  297. _this.$refs.table.refresh()
  298. _this.spinning = false
  299. } else {
  300. _this.spinning = false
  301. }
  302. })
  303. }
  304. })
  305. },
  306. // 重置
  307. resetSearchForm (flag) {
  308. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  309. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  310. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  311. this.queryParam.orderBundleNo = ''
  312. this.queryParam.purchaseBillNo = ''
  313. this.queryParam.purchaseTargetSn = undefined
  314. this.queryParam.purchaseTargetType = undefined
  315. this.queryParam.billStatus = undefined
  316. this.queryParam.financialStatus = undefined
  317. this.queryParam.purchaseBillSource = undefined
  318. this.queryParam.promotionFlag = undefined
  319. if (!flag) {
  320. this.$refs.table.refresh(true)
  321. this.setIsHomeNav(this.$route.name, null)
  322. }
  323. },
  324. filterOption (input, option) {
  325. return (
  326. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  327. )
  328. },
  329. // 获取供应商数据
  330. getSupperList () {
  331. queryReturnSupplierList({}).then(res => {
  332. if (res.status == 200) {
  333. this.supplierList = res.data
  334. } else {
  335. this.supplierList = []
  336. }
  337. })
  338. },
  339. pageInit () {
  340. const _this = this
  341. this.$nextTick(() => { // 页面渲染完成后的回调
  342. _this.setTableH()
  343. })
  344. this.openModal = false
  345. this.getSupperList()
  346. // 是否打开的页签
  347. const a = this.$store.state.app.isNewTab
  348. // 是否要刷新列表
  349. const b = this.$store.state.app.updateList
  350. // 是否从首页点击进入
  351. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  352. // 从首页进入,判断式新建还式待办查询
  353. if (isHomeNav) {
  354. // 新增
  355. if (isHomeNav.type == 'new') {
  356. this.resetSearchForm()
  357. this.openModal = true
  358. }
  359. // 待办
  360. if (isHomeNav.type == 'todo') {
  361. this.resetSearchForm(true)
  362. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  363. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  364. this.$refs.table.refresh(true)
  365. }
  366. } else {
  367. // 如果是新页签打开,则重置当前页面
  368. if (a && !b) {
  369. this.resetSearchForm()
  370. }
  371. }
  372. // 仅刷新列表,不重置页面
  373. if (b || a == b) {
  374. this.$refs.table.refresh()
  375. }
  376. },
  377. setTableH () {
  378. const tableSearchH = this.$refs.tableSearch.offsetHeight
  379. this.tableHeight = window.innerHeight - tableSearchH - 275
  380. }
  381. },
  382. watch: {
  383. advanced (newValue, oldValue) {
  384. const _this = this
  385. this.$nextTick(() => { // 页面渲染完成后的回调
  386. _this.setTableH()
  387. })
  388. },
  389. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  390. this.setTableH()
  391. }
  392. },
  393. activated () {
  394. this.pageInit()
  395. },
  396. beforeRouteEnter (to, from, next) {
  397. next(vm => {
  398. })
  399. }
  400. }
  401. </script>