list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <a-card size="small" :bordered="false" class="purchaseOrderList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <rangeDate ref="rangeDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="采购单号">
  14. <a-input id="purchaseOrderList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="供应商" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  19. <a-select
  20. id="purchaseOrderList-dealerSn"
  21. placeholder="请选择供应商"
  22. allowClear
  23. v-model="queryParam.dealerSn"
  24. :showSearch="true"
  25. option-filter-prop="children"
  26. :filter-option="filterOption">
  27. <a-select-option v-for="item in supplierList" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
  28. </a-select>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24" v-show="advanced">
  32. <a-form-item label="业务状态">
  33. <v-select
  34. v-model="queryParam.billStatus"
  35. ref="billStatus"
  36. id="purchaseOrderList-billStatus"
  37. code="PURCHASE_BILL_STATUS"
  38. placeholder="请选择业务状态"
  39. allowClear></v-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">
  54. <span class="table-page-search-submitButtons">
  55. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOrderList-refresh">查询</a-button>
  56. <a-button style="margin-left: 8px" @click="resetSearchForm()" :disabled="disabled" id="purchaseOrderList-reset">重置</a-button>
  57. <a @click="advanced=!advanced" style="margin-left: 8px">
  58. {{ advanced ? '收起' : '展开' }}
  59. <a-icon :type="advanced ? 'up' : 'down'"/>
  60. </a>
  61. </span>
  62. </a-col>
  63. </a-row>
  64. </a-form>
  65. </div>
  66. <!-- 操作按钮 -->
  67. <div class="table-operator">
  68. <a-button id="purchaseOrderList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  69. </div>
  70. <!-- alert -->
  71. <a-alert type="info" showIcon style="margin-bottom:15px">
  72. <div slot="message">共 <strong>{{ totalData.totalRecord }}</strong> 条记录,采购数量合计 <strong>{{ totalData.totalQty }}</strong> ,采购金额合计¥<strong>{{ totalData.totalAmount }}</strong> </div>
  73. </a-alert>
  74. <!-- 列表 -->
  75. <s-table
  76. class="sTable"
  77. ref="table"
  78. size="default"
  79. :rowKey="(record) => record.id"
  80. :columns="columns"
  81. :data="loadData"
  82. :scroll="{ x: 1495, y: tableHeight }"
  83. bordered>
  84. <!-- 采购单号 -->
  85. <template slot="purchaseBillNo" slot-scope="text, record">
  86. <span style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.purchaseBillNo }}</span>
  87. </template>
  88. <!-- 财务状态 -->
  89. <template slot="financialStatus" slot-scope="text, record">
  90. <a-badge :color="text=='FINISH'?'#87d068':'gold'" :text="$refs.financialStatus.getNameByCode(text)" />
  91. </template>
  92. <!-- 业务状态 -->
  93. <template slot="billStatus" slot-scope="text, record">
  94. {{ $refs.billStatus.getNameByCode(text) }}
  95. </template>
  96. <!-- 操作 -->
  97. <template slot="action" slot-scope="text, record">
  98. <a-button
  99. size="small"
  100. type="link"
  101. class="button-info"
  102. v-if="record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT'"
  103. @click="handleEdit(record)"
  104. >编辑</a-button>
  105. <a-button
  106. size="small"
  107. type="link"
  108. class="button-warning"
  109. v-if="record.billStatus == 'WAIT_PUT_WAREHOUSE'"
  110. @click="handleWarehouse(record)"
  111. >签收入库</a-button>
  112. <a-button
  113. size="small"
  114. type="link"
  115. class="button-error"
  116. v-if="record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT'"
  117. @click="handleDel(record)"
  118. >删除</a-button>
  119. <span v-if="record.billStatus != 'WAIT_SUBMIT'&&record.billStatus != 'AUDIT_REJECT'&&record.billStatus != 'WAIT_PUT_WAREHOUSE'">--</span>
  120. </template>
  121. </s-table>
  122. <!-- 选择基本信息弹框 -->
  123. <basic-info-modal :openModal="openModal" @ok="handleOk" @cancel="openModal=false" />
  124. </a-card>
  125. </template>
  126. <script>
  127. import { STable, VSelect } from '@/components'
  128. import rangeDate from '@/views/common/rangeDate.vue'
  129. import basicInfoModal from './basicInfoModal.vue'
  130. import { purchaseList, purchaseDel, purchaseCount, getParentDealer } from '@/api/purchase'
  131. export default {
  132. components: { STable, VSelect, basicInfoModal, rangeDate },
  133. data () {
  134. return {
  135. advanced: false, // 高级搜索 展开/关闭
  136. disabled: false, // 查询、重置按钮是否可操作
  137. openModal: false, // 基本信息弹框是否显示
  138. supplierList: [],
  139. tableHeight: 0,
  140. // 查询参数
  141. queryParam: {
  142. purchaseBillNo: '',
  143. dealerSn: undefined,
  144. billStatus: undefined,
  145. financialStatus: undefined,
  146. beginDate: '',
  147. endDate: ''
  148. },
  149. totalData: {
  150. totalRecord: 0,
  151. totalCategory: 0,
  152. totalQty: 0,
  153. totalAmount: 0
  154. },
  155. // 表头
  156. columns: [
  157. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  158. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: 220, align: 'center' },
  159. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '供应商', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '产品款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  162. { title: '采购数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  163. { title: '采购金额(¥)', dataIndex: 'totalAmount', width: 115, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  164. { title: '业务状态', dataIndex: 'billStatus', scopedSlots: { customRender: 'billStatus' }, width: 110, align: 'center' },
  165. { title: '财务状态', dataIndex: 'financialStatus', scopedSlots: { customRender: 'financialStatus' }, width: 100, align: 'center' },
  166. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  167. ],
  168. // 加载数据方法 必须为 Promise 对象
  169. loadData: parameter => {
  170. this.disabled = true
  171. if (this.tableHeight == 0) {
  172. this.tableHeight = window.innerHeight - 440
  173. }
  174. // 获取统计数据
  175. this.getTotalData(Object.assign(parameter, this.queryParam))
  176. return purchaseList(Object.assign(parameter, this.queryParam)).then(res => {
  177. const data = res.data
  178. const no = (data.pageNo - 1) * data.pageSize
  179. for (var i = 0; i < data.list.length; i++) {
  180. data.list[i].no = no + i + 1
  181. }
  182. this.disabled = false
  183. return data
  184. })
  185. }
  186. }
  187. },
  188. methods: {
  189. getTotalData (params) {
  190. purchaseCount(params).then(res => {
  191. this.totalData = res.data || null
  192. })
  193. },
  194. // 时间 change
  195. dateChange (date) {
  196. this.queryParam.beginDate = date[0]
  197. this.queryParam.endDate = date[1]
  198. },
  199. // 新增
  200. handleAdd () {
  201. this.openModal = true
  202. },
  203. // 基本信息 保存
  204. handleOk (row) {
  205. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn } })
  206. },
  207. // 编辑
  208. handleEdit (row) {
  209. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn } })
  210. },
  211. // 详情
  212. handleDetail (row) {
  213. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  214. },
  215. // 签收入库
  216. handleWarehouse (row) {
  217. this.$router.push({ name: `purchaseOrderWarehousing`, params: { sn: row.purchaseBillSn } })
  218. },
  219. // 删除
  220. handleDel (row) {
  221. const _this = this
  222. this.$confirm({
  223. title: '提示',
  224. content: '删除后不可恢复,确定要进行删除吗?',
  225. centered: true,
  226. onOk () {
  227. purchaseDel({
  228. id: row.id
  229. }).then(res => {
  230. if (res.status == 200) {
  231. _this.$message.success(res.message)
  232. _this.$refs.table.refresh()
  233. }
  234. })
  235. }
  236. })
  237. },
  238. // 重置
  239. resetSearchForm () {
  240. this.$refs.rangeDate.resetDate()
  241. this.queryParam.beginDate = ''
  242. this.queryParam.endDate = ''
  243. this.queryParam.orderBundleNo = ''
  244. this.queryParam.purchaseBillNo = ''
  245. this.queryParam.dealerSn = ''
  246. this.queryParam.billStatus = undefined
  247. this.queryParam.financialStatus = undefined
  248. this.$refs.table.refresh(true)
  249. },
  250. filterOption (input, option) {
  251. return (
  252. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  253. )
  254. },
  255. // 获取供应商数据
  256. getSupperList () {
  257. this.supplierList = [{ dealerSn: '1', dealerName: '箭冠营销中心' }]
  258. getParentDealer({}).then(res => {
  259. if (res.status == 200) {
  260. this.purchaseTragetType = res.data
  261. if (res.data) {
  262. this.supplierList.push({ dealerSn: res.data.dealerSn, dealerName: res.data.dealerName })
  263. }
  264. }
  265. })
  266. }
  267. },
  268. beforeRouteEnter (to, from, next) {
  269. next(vm => {
  270. vm.openModal = false
  271. vm.getSupperList()
  272. })
  273. }
  274. }
  275. </script>
  276. <style lang="less">
  277. .purchaseOrderList-wrap{
  278. .sTable{
  279. margin-top: 15px;
  280. }
  281. }
  282. </style>