list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. @click="handleWarehouse(record)"
  119. >签收入库</a-button>
  120. <a-button
  121. size="small"
  122. type="link"
  123. class="button-error"
  124. @click="handleDel(record)"
  125. >删除</a-button>
  126. </template>
  127. </s-table>
  128. <!-- 选择基本信息弹框 -->
  129. <basic-info-modal :openModal="openModal" @ok="handleOk" @cancel="openModal=false" />
  130. </a-card>
  131. </template>
  132. <script>
  133. import { STable, VSelect } from '@/components'
  134. import basicInfoModal from './basicInfoModal.vue'
  135. import { purchaseList, purchaseDel, purchaseCount } from '@/api/purchase'
  136. import { supplierAllList } from '@/api/supplier'
  137. import moment from 'moment'
  138. export default {
  139. components: { STable, VSelect, basicInfoModal },
  140. data () {
  141. return {
  142. advanced: false, // 高级搜索 展开/关闭
  143. disabled: false, // 查询、重置按钮是否可操作
  144. openModal: false, // 基本信息弹框是否显示
  145. supplierList: [],
  146. dateFormat: 'YYYY-MM-DD',
  147. time: [], // 创建时间
  148. // 查询参数
  149. queryParam: {
  150. purchaseBillNo: '',
  151. supplierSn: '',
  152. billStatus: undefined,
  153. financialStatus: undefined,
  154. beginDate: '',
  155. endDate: ''
  156. },
  157. totalData: {
  158. totalRecord: 0,
  159. totalCategory: 0,
  160. totalQty: 0,
  161. totalAmount: 0
  162. },
  163. // 表头
  164. columns: [
  165. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  166. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: 200, align: 'center' },
  167. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '供应商', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '产品款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  170. { title: '采购数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  171. { title: '采购金额(¥)', dataIndex: 'totalAmount', width: 115, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  172. { title: '业务状态', dataIndex: 'billStatusDictValue', width: 110, align: 'center' },
  173. { title: '财务状态', dataIndex: 'financialStatus', scopedSlots: { customRender: 'financialStatus' }, width: 100, align: 'center' },
  174. { title: '操作', scopedSlots: { customRender: 'action' }, width: 350, align: 'center', fixed: 'right' }
  175. ],
  176. // 加载数据方法 必须为 Promise 对象
  177. loadData: parameter => {
  178. this.disabled = true
  179. // 创建时间
  180. if (this.time && this.time.length > 0) {
  181. this.queryParam.beginDate = moment(this.time[0]).format(this.dateFormat)
  182. this.queryParam.endDate = moment(this.time[1]).format(this.dateFormat)
  183. } else {
  184. this.queryParam.beginDate = undefined
  185. this.queryParam.endDate = undefined
  186. }
  187. // 获取统计数据
  188. this.getTotalData(Object.assign(parameter, this.queryParam))
  189. return purchaseList(Object.assign(parameter, this.queryParam)).then(res => {
  190. const data = res.data
  191. const no = (data.pageNo - 1) * data.pageSize
  192. for (var i = 0; i < data.list.length; i++) {
  193. data.list[i].no = no + i + 1
  194. }
  195. this.disabled = false
  196. return data
  197. })
  198. }
  199. }
  200. },
  201. methods: {
  202. getTotalData (params) {
  203. purchaseCount(params).then(res => {
  204. this.totalData = res.data || null
  205. })
  206. },
  207. // 不可选日期
  208. disabledDate (date, dateStrings) {
  209. return date && date.valueOf() > Date.now()
  210. },
  211. // 新增
  212. handleAdd () {
  213. this.openModal = true
  214. },
  215. // 基本信息 保存
  216. handleOk (row) {
  217. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn } })
  218. },
  219. // 编辑
  220. handleEdit (row) {
  221. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn } })
  222. },
  223. // 详情
  224. handleDetail (row) {
  225. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  226. },
  227. // 签收入库
  228. handleWarehouse (row) {
  229. this.$router.push({ name: `purchaseOrderWarehousing`, params: { sn: row.purchaseBillSn } })
  230. },
  231. // 删除
  232. handleDel (row) {
  233. const _this = this
  234. this.$confirm({
  235. title: '提示',
  236. content: '删除后不可恢复,确定要进行删除吗?',
  237. centered: true,
  238. onOk () {
  239. purchaseDel({
  240. id: row.id
  241. }).then(res => {
  242. if (res.status == 200) {
  243. _this.$message.success(res.message)
  244. _this.$refs.table.refresh()
  245. }
  246. })
  247. }
  248. })
  249. },
  250. // 重置
  251. resetSearchForm () {
  252. this.queryParam.orderBundleNo = ''
  253. this.queryParam.purchaseBillNo = ''
  254. this.queryParam.supplierSn = ''
  255. this.queryParam.billStatus = undefined
  256. this.queryParam.financialStatus = undefined
  257. this.queryParam.beginDate = ''
  258. this.queryParam.endDate = ''
  259. this.time = []
  260. this.$refs.table.refresh(true)
  261. },
  262. filterOption (input, option) {
  263. return (
  264. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  265. )
  266. },
  267. // 获取供应商数据
  268. getSupperList () {
  269. supplierAllList().then(res => {
  270. this.supplierList = res.data || []
  271. })
  272. }
  273. },
  274. beforeRouteEnter (to, from, next) {
  275. next(vm => {
  276. vm.openModal = false
  277. vm.getSupperList()
  278. })
  279. }
  280. }
  281. </script>
  282. <style lang="less">
  283. .purchaseOrderList-wrap{
  284. .sTable{
  285. margin-top: 15px;
  286. }
  287. }
  288. </style>