list.vue 17 KB

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