list.vue 12 KB

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