list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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: 'PurchaseOrderNewList',
  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: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  212. ],
  213. // 加载数据方法 必须为 Promise 对象
  214. loadData: parameter => {
  215. this.disabled = true
  216. this.spinning = true
  217. // 获取统计数据
  218. this.getTotalData(Object.assign(parameter, this.queryParam))
  219. return purchaseList(Object.assign(parameter, this.queryParam)).then(res => {
  220. let data
  221. if (res.status == 200) {
  222. data = res.data
  223. const no = (data.pageNo - 1) * data.pageSize
  224. for (var i = 0; i < data.list.length; i++) {
  225. data.list[i].no = no + i + 1
  226. }
  227. this.disabled = false
  228. }
  229. this.spinning = false
  230. return data
  231. })
  232. }
  233. }
  234. },
  235. methods: {
  236. getTotalData (params) {
  237. purchaseCount(params).then(res => {
  238. this.totalData = res.data || null
  239. })
  240. },
  241. // 供应商change
  242. tragetTypeChange (val) {
  243. const ind = this.supplierList.findIndex(item => item.purchaseTargetSn == val)
  244. if (ind != -1) {
  245. this.queryParam.purchaseTargetType = this.supplierList[ind].purchaseTargetType
  246. } else {
  247. this.queryParam.purchaseTargetSn = undefined
  248. this.queryParam.purchaseTargetType = undefined
  249. }
  250. },
  251. // 时间 change
  252. dateChange (date) {
  253. this.queryParam.beginDate = date[0]
  254. this.queryParam.endDate = date[1]
  255. },
  256. // 新增
  257. handleAdd () {
  258. this.openModal = true
  259. },
  260. // 基本信息 保存
  261. handleOk (row) {
  262. this.$router.push({ name: `purchaseOrderNewAdd`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  263. },
  264. // 编辑
  265. handleEdit (row) {
  266. this.$router.push({ name: `purchaseOrderNewEdit`, params: { sn: row.purchaseBillSn, dealerSn: (row.purchaseTargetType == 'DEALER_UP' ? row.purchaseTargetSn : 'NONE') } })
  267. },
  268. // 详情
  269. handleDetail (row) {
  270. this.$router.push({ name: `purchaseOrderNewDetail`, params: { sn: row.purchaseBillSn } })
  271. },
  272. // 删除
  273. handleDel (row) {
  274. const _this = this
  275. this.$confirm({
  276. title: '提示',
  277. content: '删除后不可恢复,确定要进行删除吗?',
  278. centered: true,
  279. onOk () {
  280. _this.spinning = true
  281. purchaseDel({
  282. id: row.id
  283. }).then(res => {
  284. if (res.status == 200) {
  285. _this.$message.success(res.message)
  286. _this.$refs.table.refresh()
  287. _this.spinning = false
  288. } else {
  289. _this.spinning = false
  290. }
  291. })
  292. }
  293. })
  294. },
  295. // 重置
  296. resetSearchForm (flag) {
  297. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  298. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  299. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  300. this.queryParam.orderBundleNo = ''
  301. this.queryParam.purchaseBillNo = ''
  302. this.queryParam.purchaseTargetSn = undefined
  303. this.queryParam.purchaseTargetType = undefined
  304. this.queryParam.billStatus = undefined
  305. this.queryParam.financialStatus = undefined
  306. this.queryParam.purchaseBillSource = undefined
  307. if (!flag) {
  308. this.$refs.table.refresh(true)
  309. this.setIsHomeNav(this.$route.name, null)
  310. }
  311. },
  312. filterOption (input, option) {
  313. return (
  314. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  315. )
  316. },
  317. // 获取供应商数据
  318. getSupperList () {
  319. queryReturnSupplierList({}).then(res => {
  320. if (res.status == 200) {
  321. this.supplierList = res.data
  322. } else {
  323. this.supplierList = []
  324. }
  325. })
  326. },
  327. pageInit () {
  328. const _this = this
  329. this.$nextTick(() => { // 页面渲染完成后的回调
  330. _this.setTableH()
  331. })
  332. this.openModal = false
  333. this.getSupperList()
  334. // 是否打开的页签
  335. const a = this.$store.state.app.isNewTab
  336. // 是否要刷新列表
  337. const b = this.$store.state.app.updateList
  338. // 是否从首页点击进入
  339. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  340. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  341. // 从首页进入,判断式新建还式待办查询
  342. if (isHomeNav) {
  343. // 新增
  344. if (isHomeNav.type == 'new') {
  345. this.resetSearchForm()
  346. this.openModal = true
  347. }
  348. // 待办
  349. if (isHomeNav.type == 'todo') {
  350. this.resetSearchForm(true)
  351. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  352. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  353. this.$refs.table.refresh(true)
  354. }
  355. } else {
  356. // 如果是新页签打开,则重置当前页面
  357. if (a && !b) {
  358. this.resetSearchForm()
  359. }
  360. }
  361. // 仅刷新列表,不重置页面
  362. if (b || a == b) {
  363. this.$refs.table.refresh()
  364. }
  365. },
  366. setTableH () {
  367. const tableSearchH = this.$refs.tableSearch.offsetHeight
  368. this.tableHeight = window.innerHeight - tableSearchH - 275
  369. }
  370. },
  371. watch: {
  372. advanced (newValue, oldValue) {
  373. const _this = this
  374. this.$nextTick(() => { // 页面渲染完成后的回调
  375. _this.setTableH()
  376. })
  377. },
  378. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  379. this.setTableH()
  380. }
  381. },
  382. activated () {
  383. this.pageInit()
  384. },
  385. beforeRouteEnter (to, from, next) {
  386. next(vm => {
  387. })
  388. }
  389. }
  390. </script>