list.vue 19 KB

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