list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-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" :value="time" @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="bulkWarehousingOrderList-sparePartsPurchaseNo" v-model.trim="queryParam.sparePartsPurchaseNo" 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="bulkWarehousingOrderList-supplierSn"
  22. placeholder="请选择供应商"
  23. allowClear
  24. v-model="queryParam.supplierSn"
  25. :showSearch="true"
  26. option-filter-prop="children"
  27. :filter-option="filterOption">
  28. <a-select-option v-for="item in supplierList" :key="item.supplierSn" :value="item.supplierSn">{{ item.supplierName }}</a-select-option>
  29. </a-select>
  30. </a-form-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="业务状态">
  35. <v-select
  36. v-model="queryParam.state"
  37. ref="state"
  38. id="bulkWarehousingOrderList-state"
  39. code="SPARE_PARTS_PURCHASE"
  40. placeholder="请选择业务状态"
  41. allowClear
  42. ></v-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="财务状态">
  47. <v-select
  48. v-model="queryParam.settleState"
  49. ref="settleState"
  50. id="bulkWarehousingOrderList-settleState"
  51. code="FINANCIAL_PAY_STATUS"
  52. placeholder="请选择财务状态"
  53. allowClear
  54. ></v-select>
  55. </a-form-item>
  56. </a-col>
  57. </template>
  58. <a-col :md="6" :sm="24">
  59. <span class="table-page-search-submitButtons">
  60. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderList-refresh">查询</a-button>
  61. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="bulkWarehousingOrderList-reset">重置</a-button>
  62. <a-button
  63. style="margin-left: 5px"
  64. type="primary"
  65. class="button-warning"
  66. @click="handleExport"
  67. :disabled="disabled"
  68. :loading="exportLoading"
  69. v-if="$hasPermissions('B_bulkWarehousingOrder_export')"
  70. id="bulkWarehousingOrderList-export">导出</a-button>
  71. <a @click="advanced=!advanced" style="margin-left: 5px">
  72. {{ advanced ? '收起' : '展开' }}
  73. <a-icon :type="advanced ? 'up' : 'down'"/>
  74. </a>
  75. </span>
  76. </a-col>
  77. </a-row>
  78. </a-form>
  79. </div>
  80. <!-- 操作按钮 -->
  81. <div class="table-operator">
  82. <a-button v-if="$hasPermissions('B_bulkWarehousingOrder_add')" id="bulkWarehousingOrderList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  83. </div>
  84. <!-- alert -->
  85. <a-alert type="info" style="margin-bottom:10px">
  86. <div slot="message">
  87. 共 <strong>{{ dataTotalCount }}</strong> 条记录,
  88. 总数量合计 <strong>{{ productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0) ? productTotal.productTotalQty : '--' }}</strong> ,
  89. 总金额合计 <strong>{{ productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
  90. </div>
  91. </a-alert>
  92. <!-- 列表 -->
  93. <s-table
  94. class="sTable fixPagination"
  95. ref="table"
  96. :style="{ height: tableHeight+84.5+'px' }"
  97. size="small"
  98. :rowKey="(record) => record.id"
  99. :columns="columns"
  100. :data="loadData"
  101. :scroll="{ y: tableHeight }"
  102. :defaultLoadData="false"
  103. bordered>
  104. <!-- 散件单号 -->
  105. <template slot="sparePartsPurchaseNo" slot-scope="text, record">
  106. <span v-if="$hasPermissions('B_bulkWarehousingOrder_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.sparePartsPurchaseNo }}</span>
  107. <span v-else>{{ record.sparePartsPurchaseNo }}</span>
  108. </template>
  109. <!-- 提交 -->
  110. <template slot="submit" slot-scope="text, record">
  111. <stateIcon :state="record.state != 'WAIT_SUBMIT'?'1':'2'"></stateIcon>
  112. </template>
  113. <!-- 入库 -->
  114. <template slot="waitOut" slot-scope="text, record">
  115. <stateIcon :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  116. </template>
  117. <!-- 付款 -->
  118. <template slot="financial" slot-scope="text, record">
  119. <stateIcon :state="record.settleState == 'FINISH'?'1':'2'"></stateIcon>
  120. </template>
  121. <!-- 操作 -->
  122. <template slot="action" slot-scope="text, record">
  123. <a-button
  124. size="small"
  125. type="link"
  126. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_edit')"
  127. @click="handleEdit(record)"
  128. class="button-primary"
  129. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  130. <a-button
  131. size="small"
  132. type="link"
  133. v-if="record.state == 'WAIT_PUT_WAREHOUSE' && $hasPermissions('B_bulkWarehousingOrder_put')"
  134. @click="handleWarehouse(record)"
  135. class="button-primary"
  136. id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
  137. <a-button
  138. size="small"
  139. type="link"
  140. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_del')"
  141. @click="handleDel(record)"
  142. class="button-error"
  143. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  144. <span v-if="(record.state == 'FINISH' || !$hasPermissions('B_bulkWarehousingOrder_edit')) &&(record.state == 'FINISH' || !$hasPermissions('B_bulkWarehousingOrder_del')) &&(record.state != 'WAIT_PUT_WAREHOUSE' || !$hasPermissions('B_bulkWarehousingOrder_put'))">--</span>
  145. </template>
  146. </s-table>
  147. </a-spin>
  148. <!-- 选择基本信息弹框 -->
  149. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  150. </a-card>
  151. </template>
  152. <script>
  153. import { commonMixin } from '@/utils/mixin'
  154. import { STable, VSelect } from '@/components'
  155. import rangeDate from '@/views/common/rangeDate.vue'
  156. import getDate from '@/libs/getDate.js'
  157. import basicInfoModal from './basicInfoModal.vue'
  158. import { sparePartsPurList, sparePartsPurCount, sparePartsPurDel, sparePartsPurPut, sparePartsPurExport } from '@/api/sparePartsPur'
  159. import { supplierAllList } from '@/api/supplier'
  160. import { downloadExcel } from '@/libs/JGPrint.js'
  161. import stateIcon from '@/views/common/stateIcon'
  162. export default {
  163. name: 'BulkWarehousingList',
  164. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon },
  165. mixins: [commonMixin],
  166. data () {
  167. return {
  168. spinning: false,
  169. advanced: true, // 高级搜索 展开/关闭
  170. disabled: false, // 查询、重置按钮是否可操作
  171. exportLoading: false, // 导出loading
  172. openModal: false, // 基本信息弹框是否显示
  173. supplierList: [], // 供应商列表数据
  174. tableHeight: 0,
  175. time: [
  176. getDate.getCurrMonthDays().starttime,
  177. getDate.getCurrMonthDays().endtime
  178. ],
  179. // 查询参数
  180. queryParam: {
  181. beginDate: getDate.getCurrMonthDays().starttime,
  182. endDate: getDate.getCurrMonthDays().endtime,
  183. sparePartsPurchaseNo: '', // 散件单号
  184. supplierSn: undefined, // 供应商
  185. state: undefined, // 单据状态
  186. settleState: undefined // 结算状态
  187. },
  188. // 表头
  189. columns: [
  190. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  191. { title: '散件单号', scopedSlots: { customRender: 'sparePartsPurchaseNo' }, width: '15%', align: 'center' },
  192. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '供应商', dataIndex: 'supplierName', width: '23%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  194. { title: '产品款数', dataIndex: 'productTotalCategory', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  195. { title: '总数量', dataIndex: 'productTotalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  196. { title: '总金额', dataIndex: 'productTotalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  197. { title: '业务状态', dataIndex: 'stateDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '提交', scopedSlots: { customRender: 'submit' }, width: '2%', align: 'center' },
  199. { title: '入库', scopedSlots: { customRender: 'waitOut' }, width: '2%', align: 'center' },
  200. { title: '付款', scopedSlots: { customRender: 'financial' }, width: '2%', align: 'center' },
  201. // { title: '财务状态', dataIndex: 'settleStateDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  202. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  203. ],
  204. // 加载数据方法 必须为 Promise 对象
  205. loadData: parameter => {
  206. this.disabled = true
  207. this.spinning = true
  208. return sparePartsPurList(Object.assign(parameter, this.queryParam)).then(res => {
  209. let data
  210. if (res.status == 200) {
  211. data = res.data
  212. this.getTotal(Object.assign(parameter, this.queryParam))
  213. const no = (data.pageNo - 1) * data.pageSize
  214. for (var i = 0; i < data.list.length; i++) {
  215. data.list[i].no = no + i + 1
  216. }
  217. this.disabled = false
  218. this.dataTotalCount = data.count || 0
  219. }
  220. this.spinning = false
  221. return data
  222. })
  223. },
  224. productTotal: null,
  225. dataTotalCount: 0 // 列表数据总条数
  226. }
  227. },
  228. methods: {
  229. // 时间 change
  230. dateChange (date) {
  231. this.queryParam.beginDate = date[0]
  232. this.queryParam.endDate = date[1]
  233. },
  234. // 合计
  235. getTotal (param) {
  236. sparePartsPurCount(param).then(res => {
  237. if (res.status == 200 && res.data) {
  238. this.productTotal = res.data
  239. } else {
  240. this.productTotal = null
  241. }
  242. })
  243. },
  244. // 新增
  245. handleAdd () {
  246. this.openModal = true
  247. },
  248. // 基本信息 保存
  249. handleOk (row) {
  250. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsPurchaseSn}/${row.supplierSn}` })
  251. },
  252. // 编辑
  253. handleEdit (row) {
  254. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsPurchaseSn}/${row.supplierSn}` })
  255. },
  256. // 详情
  257. handleDetail (row) {
  258. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
  259. },
  260. // 入库
  261. handleWarehouse (row) {
  262. const _this = this
  263. this.$confirm({
  264. title: '提示',
  265. content: '确定要入库吗?',
  266. centered: true,
  267. onOk () {
  268. _this.spinning = true
  269. sparePartsPurPut({ id: row.id }).then(res => {
  270. if (res.status == 200) {
  271. _this.$message.success(res.message)
  272. _this.$refs.table.refresh()
  273. _this.spinning = false
  274. } else {
  275. _this.spinning = false
  276. }
  277. })
  278. }
  279. })
  280. },
  281. // 删除
  282. handleDel (row) {
  283. const _this = this
  284. this.$confirm({
  285. title: '提示',
  286. content: '删除后不可恢复,确定要进行删除吗?',
  287. centered: true,
  288. onOk () {
  289. _this.spinning = true
  290. sparePartsPurDel({ id: row.id }).then(res => {
  291. if (res.status == 200) {
  292. _this.$message.success(res.message)
  293. _this.$refs.table.refresh()
  294. _this.spinning = false
  295. } else {
  296. _this.spinning = false
  297. }
  298. })
  299. }
  300. })
  301. },
  302. // 重置
  303. resetSearchForm () {
  304. this.resetData()
  305. this.$refs.table.refresh(true)
  306. },
  307. // 重置数据
  308. resetData () {
  309. this.$refs.rangeDate.resetDate(this.time)
  310. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  311. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  312. this.queryParam.sparePartsPurchaseNo = ''
  313. this.queryParam.supplierSn = undefined
  314. this.queryParam.state = undefined
  315. this.queryParam.settleState = undefined
  316. },
  317. filterOption (input, option) {
  318. return (
  319. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  320. )
  321. },
  322. // 导出
  323. handleExport () {
  324. const _this = this
  325. const params = this.queryParam
  326. this.exportLoading = true
  327. this.spinning = true
  328. sparePartsPurExport(params).then(res => {
  329. this.exportLoading = false
  330. this.spinning = false
  331. if (res.type == 'application/json') {
  332. var reader = new FileReader()
  333. reader.addEventListener('loadend', function () {
  334. const obj = JSON.parse(reader.result)
  335. _this.$notification.error({
  336. message: '提示',
  337. description: obj.message
  338. })
  339. })
  340. reader.readAsText(res)
  341. } else {
  342. downloadExcel(res, '散件入库单')
  343. }
  344. })
  345. },
  346. // 供应商下拉数据
  347. getSupplierList () {
  348. supplierAllList().then(res => {
  349. if (res.status == 200) {
  350. this.supplierList = res.data
  351. } else {
  352. this.supplierList = []
  353. }
  354. })
  355. },
  356. pageInit () {
  357. const _this = this
  358. this.$nextTick(() => { // 页面渲染完成后的回调
  359. _this.setTableH()
  360. })
  361. this.openModal = false
  362. this.getSupplierList()
  363. },
  364. setTableH () {
  365. const tableSearchH = this.$refs.tableSearch.offsetHeight
  366. this.tableHeight = window.innerHeight - tableSearchH - 270
  367. }
  368. },
  369. watch: {
  370. advanced (newValue, oldValue) {
  371. const _this = this
  372. this.$nextTick(() => { // 页面渲染完成后的回调
  373. _this.setTableH()
  374. })
  375. },
  376. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  377. this.setTableH()
  378. }
  379. },
  380. mounted () {
  381. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  382. this.pageInit()
  383. this.resetSearchForm()
  384. }
  385. },
  386. activated () {
  387. // 如果是新页签打开,则重置当前页面
  388. if (this.$store.state.app.isNewTab) {
  389. this.resetData()
  390. if (this.$route.query.pageParams) {
  391. this.queryParam.state = this.$route.query.pageParams.state
  392. }
  393. this.pageInit()
  394. this.$refs.table.refresh(true)
  395. }
  396. // 仅刷新列表,不重置页面
  397. if (this.$store.state.app.updateList) {
  398. this.pageInit()
  399. this.$refs.table.refresh()
  400. }
  401. },
  402. beforeRouteEnter (to, from, next) {
  403. next(vm => {})
  404. }
  405. }
  406. </script>