list.vue 15 KB

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