list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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" @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-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24" v-show="advanced">
  45. <a-form-item label="财务状态">
  46. <v-select
  47. v-model="queryParam.financialStatus"
  48. ref="financialStatus"
  49. id="purchaseOrderList-financialStatus"
  50. code="FINANCIAL_PAY_STATUS"
  51. placeholder="请选择财务状态"
  52. allowClear></v-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="单据来源">
  57. <v-select
  58. v-model="queryParam.purchaseBillSource"
  59. ref="purchaseBillSource"
  60. id="purchaseOrderList-purchaseBillSource"
  61. code="PURCHASE_SOURCE"
  62. placeholder="请选择单据来源"
  63. allowClear></v-select>
  64. </a-form-item>
  65. </a-col>
  66. <a-col :md="6" :sm="24">
  67. <span class="table-page-search-submitButtons">
  68. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOrderList-refresh">查询</a-button>
  69. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="purchaseOrderList-reset">重置</a-button>
  70. <a @click="advanced=!advanced" style="margin-left: 8px">
  71. {{ advanced ? '收起' : '展开' }}
  72. <a-icon :type="advanced ? 'up' : 'down'"/>
  73. </a>
  74. </span>
  75. </a-col>
  76. </a-row>
  77. </a-form>
  78. </div>
  79. <!-- 操作按钮 -->
  80. <div class="table-operator">
  81. <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>
  82. </div>
  83. <!-- alert -->
  84. <a-alert type="info" style="margin-bottom:10px">
  85. <div slot="message">
  86. 共 <strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong> 条记录,
  87. 采购数量合计 <strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong> ,
  88. 采购金额合计 <strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? '¥'+totalData.totalAmount : '--' }}</strong>
  89. </div>
  90. </a-alert>
  91. <!-- 列表 -->
  92. <s-table
  93. class="sTable fixPagination"
  94. ref="table"
  95. :style="{ height: tableHeight+84.5+'px' }"
  96. size="small"
  97. :rowKey="(record) => record.id"
  98. :columns="columns"
  99. :data="loadData"
  100. :scroll="{ y: tableHeight }"
  101. :defaultLoadData="false"
  102. bordered>
  103. <!-- 采购单号 -->
  104. <template slot="purchaseBillNo" slot-scope="text, record">
  105. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_purchaseDetail')" @click="handleDetail(record)">{{ record.purchaseBillNo }}</span>
  106. <span v-else>{{ record.purchaseBillNo }}</span>
  107. </template>
  108. <!-- 操作 -->
  109. <template slot="action" slot-scope="text, record">
  110. <a-button
  111. size="small"
  112. type="link"
  113. class="button-info"
  114. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')"
  115. @click="handleEdit(record)"
  116. >编辑</a-button>
  117. <a-button
  118. size="small"
  119. type="link"
  120. class="button-warning"
  121. v-if="record.billStatus == 'WAIT_PUT_WAREHOUSE'&&$hasPermissions('B_purchaseReceiving')"
  122. @click="handleWarehouse(record)"
  123. >签收入库</a-button>
  124. <a-button
  125. size="small"
  126. type="link"
  127. class="button-error"
  128. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') &&$hasPermissions('B_purchaseDel')"
  129. @click="handleDel(record)"
  130. >删除</a-button>
  131. <span v-if="record.billStatus != 'WAIT_SUBMIT'&&record.billStatus != 'AUDIT_REJECT'&&record.billStatus != 'WAIT_PUT_WAREHOUSE'">--</span>
  132. </template>
  133. </s-table>
  134. </a-spin>
  135. <!-- 选择基本信息弹框 -->
  136. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  137. </a-card>
  138. </template>
  139. <script>
  140. import { STable, VSelect } from '@/components'
  141. import rangeDate from '@/views/common/rangeDate.vue'
  142. import basicInfoModal from './basicInfoModal.vue'
  143. import { purchaseList, purchaseDel, purchaseCount, purchaseTargetList } from '@/api/purchase'
  144. export default {
  145. components: { STable, VSelect, basicInfoModal, rangeDate },
  146. data () {
  147. return {
  148. spinning: false,
  149. advanced: true, // 高级搜索 展开/关闭
  150. disabled: false, // 查询、重置按钮是否可操作
  151. openModal: false, // 基本信息弹框是否显示
  152. supplierList: [],
  153. tableHeight: 0,
  154. // 查询参数
  155. queryParam: {
  156. purchaseBillNo: '',
  157. purchaseTargetSn: undefined,
  158. purchaseTargetType: undefined,
  159. billStatus: undefined,
  160. financialStatus: undefined,
  161. purchaseBillSource: undefined,
  162. beginDate: '',
  163. endDate: ''
  164. },
  165. totalData: {
  166. totalRecord: 0,
  167. totalCategory: 0,
  168. totalQty: 0,
  169. totalAmount: 0
  170. },
  171. // 表头
  172. columns: [
  173. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  174. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: '16%', align: 'center' },
  175. { title: '创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '供应商', dataIndex: 'purchaseTargetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  177. { title: '产品款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. { title: '采购数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '缺货数量', dataIndex: 'totalCancelQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  181. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  182. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  184. ],
  185. // 加载数据方法 必须为 Promise 对象
  186. loadData: parameter => {
  187. this.disabled = true
  188. this.spinning = true
  189. // 获取统计数据
  190. this.getTotalData(Object.assign(parameter, this.queryParam))
  191. return purchaseList(Object.assign(parameter, this.queryParam)).then(res => {
  192. const data = res.data
  193. const no = (data.pageNo - 1) * data.pageSize
  194. for (var i = 0; i < data.list.length; i++) {
  195. data.list[i].no = no + i + 1
  196. }
  197. this.disabled = false
  198. this.spinning = false
  199. return data
  200. })
  201. }
  202. }
  203. },
  204. methods: {
  205. getTotalData (params) {
  206. purchaseCount(params).then(res => {
  207. this.totalData = res.data || null
  208. })
  209. },
  210. // 供应商change
  211. tragetTypeChange (val) {
  212. const ind = this.supplierList.findIndex(item => item.purchaseTargetSn == val)
  213. if (ind != -1) {
  214. this.queryParam.purchaseTargetType = this.supplierList[ind].purchaseTargetType
  215. }
  216. },
  217. // 时间 change
  218. dateChange (date) {
  219. this.queryParam.beginDate = date[0]
  220. this.queryParam.endDate = date[1]
  221. },
  222. // 新增
  223. handleAdd () {
  224. this.openModal = true
  225. },
  226. // 基本信息 保存
  227. handleOk (row) {
  228. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn } })
  229. },
  230. // 编辑
  231. handleEdit (row) {
  232. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn } })
  233. },
  234. // 详情
  235. handleDetail (row) {
  236. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  237. },
  238. // 签收入库
  239. handleWarehouse (row) {
  240. this.$router.push({ name: `purchaseOrderWarehousing`, params: { sn: row.purchaseBillSn } })
  241. },
  242. // 删除
  243. handleDel (row) {
  244. const _this = this
  245. this.$confirm({
  246. title: '提示',
  247. content: '删除后不可恢复,确定要进行删除吗?',
  248. centered: true,
  249. onOk () {
  250. _this.spinning = true
  251. purchaseDel({
  252. id: row.id
  253. }).then(res => {
  254. if (res.status == 200) {
  255. _this.$message.success(res.message)
  256. _this.$refs.table.refresh()
  257. _this.spinning = false
  258. } else {
  259. _this.spinning = false
  260. }
  261. })
  262. }
  263. })
  264. },
  265. // 重置
  266. resetSearchForm () {
  267. this.$refs.rangeDate.resetDate()
  268. this.queryParam.beginDate = ''
  269. this.queryParam.endDate = ''
  270. this.queryParam.orderBundleNo = ''
  271. this.queryParam.purchaseBillNo = ''
  272. this.queryParam.purchaseTargetSn = undefined
  273. this.queryParam.purchaseTargetType = undefined
  274. this.queryParam.billStatus = undefined
  275. this.queryParam.financialStatus = undefined
  276. this.queryParam.purchaseBillSource = undefined
  277. this.$refs.table.refresh(true)
  278. },
  279. filterOption (input, option) {
  280. return (
  281. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  282. )
  283. },
  284. // 获取供应商数据
  285. getSupperList () {
  286. purchaseTargetList({}).then(res => {
  287. if (res.status == 200) {
  288. this.supplierList = res.data
  289. } else {
  290. this.supplierList = []
  291. }
  292. })
  293. },
  294. pageInit () {
  295. const _this = this
  296. this.$nextTick(() => { // 页面渲染完成后的回调
  297. _this.setTableH()
  298. })
  299. this.openModal = false
  300. this.getSupperList()
  301. },
  302. setTableH () {
  303. const tableSearchH = this.$refs.tableSearch.offsetHeight
  304. this.tableHeight = window.innerHeight - tableSearchH - 275
  305. }
  306. },
  307. watch: {
  308. advanced (newValue, oldValue) {
  309. const _this = this
  310. setTimeout(() => {
  311. _this.setTableH()
  312. }, 400)
  313. }
  314. },
  315. mounted () {
  316. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  317. this.pageInit()
  318. this.resetSearchForm()
  319. }
  320. },
  321. activated () {
  322. // 如果是新页签打开,则重置当前页面
  323. if (this.$store.state.app.isNewTab) {
  324. this.pageInit()
  325. this.resetSearchForm()
  326. }
  327. },
  328. beforeRouteEnter (to, from, next) {
  329. next(vm => {})
  330. }
  331. }
  332. </script>