list.vue 17 KB

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