list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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. </template>
  136. <!-- 审核icon -->
  137. <template slot="audit" slot-scope="text, record">
  138. <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>
  139. <stateIcon :title="record.billStatusDictValue" v-else :state="0"></stateIcon>
  140. </template>
  141. <!-- 付款icon -->
  142. <template slot="financial" slot-scope="text, record">
  143. <stateIcon :title="record.financialStatusDictValue" :state="record.financialStatus == 'FINISH'?'1':'2'"></stateIcon>
  144. </template>
  145. <!-- 入库icon -->
  146. <template slot="waitOut" slot-scope="text, record">
  147. <stateIcon :state="record.billStatus == 'FINISH'?'1':'2'"></stateIcon>
  148. </template>
  149. <!-- 操作 -->
  150. <template slot="action" slot-scope="text, record">
  151. <a-button
  152. size="small"
  153. type="link"
  154. class="button-primary"
  155. :id="'purchaseOrderList-edit-'+record.id"
  156. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')"
  157. @click="handleEdit(record)"
  158. >编辑</a-button>
  159. <a-button
  160. size="small"
  161. type="link"
  162. class="button-error"
  163. :id="'purchaseOrderList-del-'+record.id"
  164. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT'||record.billStatus == 'CANCEL') &&$hasPermissions('B_purchaseDel')"
  165. @click="handleDel(record)"
  166. >删除</a-button>
  167. <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>
  168. </template>
  169. </s-table>
  170. </a-spin>
  171. <!-- 选择基本信息弹框 -->
  172. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  173. </a-card>
  174. </template>
  175. <script>
  176. import { commonMixin } from '@/utils/mixin'
  177. import getDate from '@/libs/getDate.js'
  178. import { STable, VSelect } from '@/components'
  179. import rangeDate from '@/views/common/rangeDate.vue'
  180. import basicInfoModal from './basicInfoModal.vue'
  181. import stateIcon from '@/views/common/stateIcon'
  182. // 接口
  183. import { purchaseList, purchaseDel, purchaseCount } from '@/api/purchase'
  184. import { queryReturnSupplierList } from '@/api/purchaseReturn'
  185. export default {
  186. name: 'PurchaseList',
  187. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon },
  188. mixins: [commonMixin],
  189. data () {
  190. return {
  191. spinning: false,
  192. advanced: true, // 高级搜索 展开/关闭
  193. disabled: false, // 查询、重置按钮是否可操作
  194. openModal: false, // 基本信息弹框是否显示
  195. supplierList: [], // 供应商列表
  196. tableHeight: 0, // 表格高度
  197. time: [ // 时间
  198. getDate.getCurrMonthDays().starttime,
  199. getDate.getCurrMonthDays().endtime
  200. ],
  201. // 查询参数
  202. queryParam: {
  203. purchaseBillNo: '', // 采购单号
  204. purchaseTargetSn: undefined, // 供应商sn
  205. purchaseTargetType: undefined, // 采购方类型
  206. billStatus: undefined, // 单据状态
  207. financialStatus: undefined, // 财务状态
  208. purchaseBillSource: undefined, // 单据来源
  209. promotionFlag: undefined, // 是否促销商品
  210. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  211. endDate: getDate.getCurrMonthDays().endtime// 结束时间
  212. },
  213. totalData: { // 统计数据
  214. totalRecord: 0, // 总条数
  215. totalCategory: 0, // 总款数
  216. totalQty: 0, // 总数量
  217. totalAmount: 0// 总金额
  218. },
  219. showCell: false, // 是否显示自定义列
  220. showOrderType: false, // 是否显示订单类型
  221. // 加载数据方法 必须为 Promise 对象
  222. loadData: parameter => {
  223. this.disabled = true
  224. this.spinning = true
  225. const params = Object.assign(parameter, this.queryParam)
  226. if (!params.billStatus) {
  227. params.billStatus = undefined
  228. }
  229. // 获取统计数据
  230. this.getTotalData(params)
  231. return purchaseList(params).then(res => {
  232. let data
  233. if (res.status == 200) {
  234. data = res.data
  235. const no = (data.pageNo - 1) * data.pageSize
  236. for (var i = 0; i < data.list.length; i++) {
  237. data.list[i].no = no + i + 1
  238. }
  239. this.disabled = false
  240. }
  241. this.spinning = false
  242. return data
  243. })
  244. }
  245. }
  246. },
  247. computed: {
  248. columns () {
  249. const _this = this
  250. const arr = [
  251. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  252. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: '13%', align: 'center' },
  253. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  254. { title: '供应商', dataIndex: 'purchaseTargetName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  255. { title: '产品款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  256. { title: '采购数量', dataIndex: 'totalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  257. { title: '采购金额', dataIndex: 'discountedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  258. { title: '审核数量', dataIndex: 'totalPushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  259. { title: '审核金额', dataIndex: 'totalPushedAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  260. { title: '已取消数量', dataIndex: 'totalCancelQty', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  261. { title: '采购状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  262. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  263. { title: '入库', scopedSlots: { customRender: 'waitOut' }, width: '3%', align: 'center' },
  264. { title: '付款', scopedSlots: { customRender: 'financial' }, width: '3%', align: 'center' },
  265. { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  266. ]
  267. if (this.showOrderType) {
  268. arr.splice(4, 0, { title: '订单类型', dataIndex: 'orderTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  269. }
  270. return arr
  271. }
  272. },
  273. methods: {
  274. // 统计信息
  275. getTotalData (params) {
  276. purchaseCount(params).then(res => {
  277. this.totalData = res.data || null
  278. })
  279. },
  280. // 供应商change
  281. tragetTypeChange (val) {
  282. const ind = this.supplierList.findIndex(item => item.purchaseTargetSn == val)
  283. if (ind != -1) {
  284. this.queryParam.purchaseTargetType = this.supplierList[ind].purchaseTargetType
  285. } else {
  286. this.queryParam.purchaseTargetSn = undefined
  287. this.queryParam.purchaseTargetType = undefined
  288. }
  289. },
  290. // 时间 change
  291. dateChange (date) {
  292. this.queryParam.beginDate = date[0]
  293. this.queryParam.endDate = date[1]
  294. },
  295. // 新增
  296. handleAdd () {
  297. this.openModal = true
  298. },
  299. // 基本信息 保存
  300. handleOk (row) {
  301. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  302. },
  303. // 编辑
  304. handleEdit (row) {
  305. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  306. },
  307. // 详情
  308. handleDetail (row) {
  309. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  310. },
  311. // 删除
  312. handleDel (row) {
  313. const _this = this
  314. this.$confirm({
  315. title: '提示',
  316. content: '删除后不可恢复,确定要进行删除吗?',
  317. centered: true,
  318. onOk () {
  319. _this.spinning = true
  320. purchaseDel({
  321. id: row.id
  322. }).then(res => {
  323. if (res.status == 200) {
  324. _this.$message.success(res.message)
  325. _this.$refs.table.refresh()
  326. _this.spinning = false
  327. } else {
  328. _this.spinning = false
  329. }
  330. })
  331. }
  332. })
  333. },
  334. // 重置
  335. resetSearchForm (flag) {
  336. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  337. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  338. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  339. this.queryParam.orderBundleNo = ''
  340. this.queryParam.purchaseBillNo = ''
  341. this.queryParam.purchaseTargetSn = undefined
  342. this.queryParam.purchaseTargetType = undefined
  343. this.queryParam.billStatus = undefined
  344. this.queryParam.financialStatus = undefined
  345. this.queryParam.purchaseBillSource = undefined
  346. this.queryParam.promotionFlag = undefined
  347. if (!flag) {
  348. this.$refs.table.refresh(true)
  349. this.setIsHomeNav(this.$route.name, null)
  350. }
  351. },
  352. // 供应商筛选
  353. filterOption (input, option) {
  354. return (
  355. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  356. )
  357. },
  358. // 获取供应商数据
  359. getSupperList () {
  360. queryReturnSupplierList({}).then(res => {
  361. if (res.status == 200) {
  362. this.supplierList = res.data
  363. } else {
  364. this.supplierList = []
  365. }
  366. })
  367. },
  368. // 页面初始化
  369. pageInit () {
  370. const _this = this
  371. this.$nextTick(() => { // 页面渲染完成后的回调
  372. _this.setTableH()
  373. })
  374. this.openModal = false
  375. this.getSupperList()
  376. // 是否打开的页签
  377. const a = this.$store.state.app.isNewTab
  378. // 是否要刷新列表
  379. const b = this.$store.state.app.updateList
  380. // 是否从首页点击进入
  381. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  382. // 从首页进入,判断式新建还式待办查询
  383. if (isHomeNav) {
  384. // 新增
  385. if (isHomeNav.type == 'new') {
  386. this.resetSearchForm()
  387. this.openModal = true
  388. }
  389. // 待办
  390. if (isHomeNav.type == 'todo') {
  391. this.resetSearchForm(true)
  392. this.$refs.rangeDate.resetDate([isHomeNav.pageParams.beginDate, isHomeNav.pageParams.endDate])
  393. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  394. this.$refs.table.refresh(true)
  395. }
  396. } else {
  397. // 如果是新页签打开,则重置当前页面
  398. if (a && !b) {
  399. this.resetSearchForm()
  400. }
  401. // 仅刷新列表,不重置页面
  402. if (b || a == b) {
  403. this.$refs.table.refresh()
  404. }
  405. }
  406. },
  407. // 表格高度计算
  408. setTableH () {
  409. const tableSearchH = this.$refs.tableSearch.offsetHeight
  410. this.tableHeight = window.innerHeight - tableSearchH - 275
  411. }
  412. },
  413. watch: {
  414. advanced (newValue, oldValue) {
  415. const _this = this
  416. this.$nextTick(() => { // 页面渲染完成后的回调
  417. _this.setTableH()
  418. })
  419. },
  420. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  421. this.setTableH()
  422. }
  423. },
  424. activated () {
  425. this.pageInit()
  426. },
  427. beforeRouteEnter (to, from, next) {
  428. next(vm => {
  429. })
  430. }
  431. }
  432. </script>