list.vue 11 KB

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