list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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" :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) ? '¥'+totalData.totalAmount : '--' }}</strong>,
  94. 审核金额合计 <strong>{{ totalData&&(totalData.totalAuthAmount || totalData.totalAuthAmount==0) ? '¥'+totalData.totalAuthAmount : '--' }}</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 style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_purchaseDetail')" @click="handleDetail(record)">{{ record.purchaseBillNo }}</span>
  112. <span v-else>{{ record.purchaseBillNo }}</span>
  113. </template>
  114. <!-- 财务状态 -->
  115. <!-- <template slot="financialStatus" slot-scope="text, record">
  116. <span>{{ record.billStatus=='FINISH'&&record.financialStatusDictValue ? record.financialStatusDictValue : '--' }}</span>
  117. </template> -->
  118. <!-- 操作 -->
  119. <template slot="action" slot-scope="text, record">
  120. <a-button
  121. size="small"
  122. type="link"
  123. class="button-info"
  124. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')"
  125. @click="handleEdit(record)"
  126. >编辑</a-button>
  127. <!-- <a-button
  128. size="small"
  129. type="link"
  130. class="button-warning"
  131. v-if="record.billStatus == 'WAIT_PUT_WAREHOUSE'&&$hasPermissions('B_purchaseReceiving')"
  132. @click="handleWarehouse(record)"
  133. >签收入库</a-button> -->
  134. <a-button
  135. size="small"
  136. type="link"
  137. class="button-error"
  138. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') &&$hasPermissions('B_purchaseDel')"
  139. @click="handleDel(record)"
  140. >删除</a-button>
  141. <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>
  142. </template>
  143. </s-table>
  144. </a-spin>
  145. <!-- 选择基本信息弹框 -->
  146. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  147. </a-card>
  148. </template>
  149. <script>
  150. import { commonMixin } from '@/utils/mixin'
  151. import { STable, VSelect } from '@/components'
  152. import rangeDate from '@/views/common/rangeDate.vue'
  153. import basicInfoModal from './basicInfoModal.vue'
  154. import getDate from '@/libs/getDate.js'
  155. import { purchaseList, purchaseDel, purchaseCount, purchaseTargetList } from '@/api/purchase'
  156. export default {
  157. name: 'PurchaseList',
  158. components: { STable, VSelect, basicInfoModal, rangeDate },
  159. mixins: [commonMixin],
  160. data () {
  161. return {
  162. spinning: false,
  163. advanced: true, // 高级搜索 展开/关闭
  164. disabled: false, // 查询、重置按钮是否可操作
  165. openModal: false, // 基本信息弹框是否显示
  166. supplierList: [],
  167. tableHeight: 0,
  168. time: [
  169. getDate.getCurrMonthDays().starttime,
  170. getDate.getCurrMonthDays().endtime
  171. ],
  172. // 查询参数
  173. queryParam: {
  174. purchaseBillNo: '',
  175. purchaseTargetSn: undefined,
  176. purchaseTargetType: undefined,
  177. billStatus: undefined,
  178. financialStatus: undefined,
  179. purchaseBillSource: undefined,
  180. beginDate: getDate.getCurrMonthDays().starttime,
  181. endDate: getDate.getCurrMonthDays().endtime
  182. },
  183. totalData: {
  184. totalRecord: 0,
  185. totalCategory: 0,
  186. totalQty: 0,
  187. totalAmount: 0
  188. },
  189. // 表头
  190. columns: [
  191. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  192. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: '14%', align: 'center' },
  193. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '供应商', dataIndex: 'purchaseTargetName', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  195. { title: '产品款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  196. { title: '采购数量', dataIndex: 'totalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  197. { title: '采购金额', dataIndex: 'discountedAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  198. { title: '审核数量', dataIndex: 'totalPushedQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  199. { title: '审核金额', dataIndex: 'totalPushedAmount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  200. { title: '已取消数量', dataIndex: 'totalCancelQty', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '采购状态', dataIndex: 'billStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  202. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  203. { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  204. ],
  205. // 加载数据方法 必须为 Promise 对象
  206. loadData: parameter => {
  207. this.disabled = true
  208. this.spinning = true
  209. // 获取统计数据
  210. this.getTotalData(Object.assign(parameter, this.queryParam))
  211. return purchaseList(Object.assign(parameter, this.queryParam)).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. }
  239. },
  240. // 时间 change
  241. dateChange (date) {
  242. this.queryParam.beginDate = date[0]
  243. this.queryParam.endDate = date[1]
  244. },
  245. // 新增
  246. handleAdd () {
  247. this.openModal = true
  248. },
  249. // 基本信息 保存
  250. handleOk (row) {
  251. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn } })
  252. },
  253. // 编辑
  254. handleEdit (row) {
  255. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn } })
  256. },
  257. // 详情
  258. handleDetail (row) {
  259. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  260. },
  261. // 签收入库
  262. handleWarehouse (row) {
  263. this.$router.push({ name: `purchaseOrderWarehousing`, params: { sn: row.purchaseBillSn } })
  264. },
  265. // 删除
  266. handleDel (row) {
  267. const _this = this
  268. this.$confirm({
  269. title: '提示',
  270. content: '删除后不可恢复,确定要进行删除吗?',
  271. centered: true,
  272. onOk () {
  273. _this.spinning = true
  274. purchaseDel({
  275. id: row.id
  276. }).then(res => {
  277. if (res.status == 200) {
  278. _this.$message.success(res.message)
  279. _this.$refs.table.refresh()
  280. _this.spinning = false
  281. } else {
  282. _this.spinning = false
  283. }
  284. })
  285. }
  286. })
  287. },
  288. // 重置
  289. resetSearchForm () {
  290. this.$refs.rangeDate.resetDate(this.time)
  291. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  292. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  293. this.queryParam.orderBundleNo = ''
  294. this.queryParam.purchaseBillNo = ''
  295. this.queryParam.purchaseTargetSn = undefined
  296. this.queryParam.purchaseTargetType = undefined
  297. this.queryParam.billStatus = undefined
  298. this.queryParam.financialStatus = undefined
  299. this.queryParam.purchaseBillSource = undefined
  300. this.$refs.table.refresh(true)
  301. },
  302. filterOption (input, option) {
  303. return (
  304. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  305. )
  306. },
  307. // 获取供应商数据
  308. getSupperList () {
  309. purchaseTargetList({}).then(res => {
  310. if (res.status == 200) {
  311. this.supplierList = res.data
  312. } else {
  313. this.supplierList = []
  314. }
  315. })
  316. },
  317. pageInit () {
  318. const _this = this
  319. this.$nextTick(() => { // 页面渲染完成后的回调
  320. _this.setTableH()
  321. })
  322. this.openModal = false
  323. this.getSupperList()
  324. },
  325. setTableH () {
  326. const tableSearchH = this.$refs.tableSearch.offsetHeight
  327. this.tableHeight = window.innerHeight - tableSearchH - 275
  328. }
  329. },
  330. watch: {
  331. advanced (newValue, oldValue) {
  332. const _this = this
  333. this.$nextTick(() => { // 页面渲染完成后的回调
  334. _this.setTableH()
  335. })
  336. },
  337. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  338. this.setTableH()
  339. }
  340. },
  341. mounted () {
  342. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  343. this.pageInit()
  344. this.resetSearchForm()
  345. }
  346. },
  347. activated () {
  348. // 如果是新页签打开,则重置当前页面
  349. if (this.$store.state.app.isNewTab) {
  350. this.pageInit()
  351. this.resetSearchForm()
  352. }
  353. // 仅刷新列表,不重置页面
  354. if (this.$store.state.app.updateList) {
  355. this.pageInit()
  356. this.$refs.table.refresh()
  357. }
  358. },
  359. beforeRouteEnter (to, from, next) {
  360. next(vm => {})
  361. }
  362. }
  363. </script>