list.vue 17 KB

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