list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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')" 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. bordered>
  102. <!-- 采购单号 -->
  103. <template slot="purchaseBillNo" slot-scope="text, record">
  104. <span style="color: #ed1c24;cursor: pointer;" v-if="$hasPermissions('B_purchaseDetail')" @click="handleDetail(record)">{{ record.purchaseBillNo }}</span>
  105. <span v-else>{{ record.purchaseBillNo }}</span>
  106. </template>
  107. <!-- 操作 -->
  108. <template slot="action" slot-scope="text, record">
  109. <a-button
  110. size="small"
  111. type="link"
  112. class="button-info"
  113. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') && $hasPermissions('B_purchaseEdit')"
  114. @click="handleEdit(record)"
  115. >编辑</a-button>
  116. <a-button
  117. size="small"
  118. type="link"
  119. class="button-warning"
  120. v-if="record.billStatus == 'WAIT_PUT_WAREHOUSE'&&$hasPermissions('B_purchaseReceiving')"
  121. @click="handleWarehouse(record)"
  122. >签收入库</a-button>
  123. <a-button
  124. size="small"
  125. type="link"
  126. class="button-error"
  127. v-if="(record.billStatus == 'WAIT_SUBMIT'||record.billStatus == 'AUDIT_REJECT') &&$hasPermissions('B_purchaseDel')"
  128. @click="handleDel(record)"
  129. >删除</a-button>
  130. <span v-if="record.billStatus != 'WAIT_SUBMIT'&&record.billStatus != 'AUDIT_REJECT'&&record.billStatus != 'WAIT_PUT_WAREHOUSE'">--</span>
  131. </template>
  132. </s-table>
  133. </a-spin>
  134. <!-- 选择基本信息弹框 -->
  135. <basic-info-modal :openModal="openModal" @ok="handleOk" @cancel="openModal=false" />
  136. </a-card>
  137. </template>
  138. <script>
  139. import { STable, VSelect } from '@/components'
  140. import rangeDate from '@/views/common/rangeDate.vue'
  141. import basicInfoModal from './basicInfoModal.vue'
  142. import { purchaseList, purchaseDel, purchaseCount, purchaseTargetList } from '@/api/purchase'
  143. export default {
  144. components: { STable, VSelect, basicInfoModal, rangeDate },
  145. data () {
  146. return {
  147. spinning: false,
  148. advanced: true, // 高级搜索 展开/关闭
  149. disabled: false, // 查询、重置按钮是否可操作
  150. openModal: false, // 基本信息弹框是否显示
  151. supplierList: [],
  152. tableHeight: 0,
  153. // 查询参数
  154. queryParam: {
  155. purchaseBillNo: '',
  156. purchaseTargetSn: undefined,
  157. purchaseTargetType: undefined,
  158. billStatus: undefined,
  159. financialStatus: undefined,
  160. purchaseBillSource: undefined,
  161. beginDate: '',
  162. endDate: ''
  163. },
  164. totalData: {
  165. totalRecord: 0,
  166. totalCategory: 0,
  167. totalQty: 0,
  168. totalAmount: 0
  169. },
  170. // 表头
  171. columns: [
  172. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  173. { title: '采购单号', scopedSlots: { customRender: 'purchaseBillNo' }, width: '16%', align: 'center' },
  174. { title: '创建时间', dataIndex: 'createDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  175. { title: '供应商', dataIndex: 'purchaseTargetName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  176. { title: '产品款数', dataIndex: 'totalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  177. { title: '采购数量', dataIndex: 'totalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. { title: '缺货数量', dataIndex: 'totalCancelQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '采购金额', dataIndex: 'discountedAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  182. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  183. ],
  184. // 加载数据方法 必须为 Promise 对象
  185. loadData: parameter => {
  186. this.disabled = true
  187. this.spinning = true
  188. // 获取统计数据
  189. this.getTotalData(Object.assign(parameter, this.queryParam))
  190. return purchaseList(Object.assign(parameter, this.queryParam)).then(res => {
  191. const data = res.data
  192. const no = (data.pageNo - 1) * data.pageSize
  193. for (var i = 0; i < data.list.length; i++) {
  194. data.list[i].no = no + i + 1
  195. }
  196. this.disabled = false
  197. this.spinning = 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. // 供应商change
  210. tragetTypeChange (val) {
  211. const ind = this.supplierList.findIndex(item => item.purchaseTargetSn == val)
  212. if (ind != -1) {
  213. this.queryParam.purchaseTargetType = this.supplierList[ind].purchaseTargetType
  214. }
  215. },
  216. // 时间 change
  217. dateChange (date) {
  218. this.queryParam.beginDate = date[0]
  219. this.queryParam.endDate = date[1]
  220. },
  221. // 新增
  222. handleAdd () {
  223. this.openModal = true
  224. },
  225. // 基本信息 保存
  226. handleOk (row) {
  227. this.$router.push({ name: `purchaseOrderAdd`, params: { sn: row.purchaseBillSn } })
  228. },
  229. // 编辑
  230. handleEdit (row) {
  231. this.$router.push({ name: `purchaseOrderEdit`, params: { sn: row.purchaseBillSn } })
  232. },
  233. // 详情
  234. handleDetail (row) {
  235. this.$router.push({ name: `purchaseOrderDetail`, params: { sn: row.purchaseBillSn } })
  236. },
  237. // 签收入库
  238. handleWarehouse (row) {
  239. this.$router.push({ name: `purchaseOrderWarehousing`, params: { sn: row.purchaseBillSn } })
  240. },
  241. // 删除
  242. handleDel (row) {
  243. const _this = this
  244. this.$confirm({
  245. title: '提示',
  246. content: '删除后不可恢复,确定要进行删除吗?',
  247. centered: true,
  248. onOk () {
  249. _this.spinning = true
  250. purchaseDel({
  251. id: row.id
  252. }).then(res => {
  253. if (res.status == 200) {
  254. _this.$message.success(res.message)
  255. _this.$refs.table.refresh()
  256. _this.spinning = false
  257. } else {
  258. _this.spinning = false
  259. }
  260. })
  261. }
  262. })
  263. },
  264. // 重置
  265. resetSearchForm () {
  266. this.$refs.rangeDate.resetDate()
  267. this.queryParam.beginDate = ''
  268. this.queryParam.endDate = ''
  269. this.queryParam.orderBundleNo = ''
  270. this.queryParam.purchaseBillNo = ''
  271. this.queryParam.purchaseTargetSn = undefined
  272. this.queryParam.purchaseTargetType = undefined
  273. this.queryParam.billStatus = undefined
  274. this.queryParam.financialStatus = undefined
  275. this.queryParam.purchaseBillSource = undefined
  276. this.$refs.table.refresh(true)
  277. },
  278. filterOption (input, option) {
  279. return (
  280. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  281. )
  282. },
  283. // 获取供应商数据
  284. getSupperList () {
  285. purchaseTargetList({}).then(res => {
  286. if (res.status == 200) {
  287. this.supplierList = res.data
  288. } else {
  289. this.supplierList = []
  290. }
  291. })
  292. },
  293. setTableH () {
  294. const tableSearchH = this.$refs.tableSearch.offsetHeight
  295. this.tableHeight = window.innerHeight - tableSearchH - 275
  296. }
  297. },
  298. mounted () {
  299. const _this = this
  300. this.$nextTick(() => { // 页面渲染完成后的回调
  301. _this.setTableH()
  302. })
  303. },
  304. watch: {
  305. advanced (newValue, oldValue) {
  306. const _this = this
  307. setTimeout(() => {
  308. _this.setTableH()
  309. }, 400)
  310. }
  311. },
  312. beforeRouteEnter (to, from, next) {
  313. next(vm => {
  314. vm.openModal = false
  315. vm.getSupperList()
  316. if (!vm.disabled) {
  317. vm.$refs.table.refresh()
  318. }
  319. })
  320. }
  321. }
  322. </script>