list.vue 19 KB

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