list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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" :pyCode="item.pyCode" :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.resetData()
  251. this.setIsHomeNav(this.$route.name, null)
  252. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsPurchaseSn}/${row.supplierSn}` })
  253. },
  254. // 编辑
  255. handleEdit (row) {
  256. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsPurchaseSn}/${row.supplierSn}` })
  257. },
  258. // 详情
  259. handleDetail (row) {
  260. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
  261. },
  262. // 入库
  263. handleWarehouse (row) {
  264. const _this = this
  265. this.$confirm({
  266. title: '提示',
  267. content: '确定要入库吗?',
  268. centered: true,
  269. onOk () {
  270. _this.spinning = true
  271. sparePartsPurPut({ id: row.id }).then(res => {
  272. if (res.status == 200) {
  273. _this.$message.success(res.message)
  274. _this.$refs.table.refresh()
  275. _this.spinning = false
  276. } else {
  277. _this.spinning = false
  278. }
  279. })
  280. }
  281. })
  282. },
  283. // 删除
  284. handleDel (row) {
  285. const _this = this
  286. this.$confirm({
  287. title: '提示',
  288. content: '删除后不可恢复,确定要进行删除吗?',
  289. centered: true,
  290. onOk () {
  291. _this.spinning = true
  292. sparePartsPurDel({ id: row.id }).then(res => {
  293. if (res.status == 200) {
  294. _this.$message.success(res.message)
  295. _this.$refs.table.refresh()
  296. _this.spinning = false
  297. } else {
  298. _this.spinning = false
  299. }
  300. })
  301. }
  302. })
  303. },
  304. // 重置
  305. resetSearchForm () {
  306. this.resetData()
  307. this.$refs.table.refresh(true)
  308. },
  309. // 重置数据
  310. resetData (flag) {
  311. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  312. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  313. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  314. this.queryParam.sparePartsPurchaseNo = ''
  315. this.queryParam.supplierSn = undefined
  316. this.queryParam.state = undefined
  317. this.queryParam.settleState = undefined
  318. },
  319. filterOption (input, option) {
  320. return (
  321. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
  322. option.data.attrs.pyCode.toLowerCase().indexOf(input.toLowerCase()) >= 0
  323. )
  324. },
  325. // 导出
  326. handleExport () {
  327. const _this = this
  328. const params = this.queryParam
  329. this.exportLoading = true
  330. this.spinning = true
  331. sparePartsPurExport(params).then(res => {
  332. this.exportLoading = false
  333. this.spinning = false
  334. if (res.type == 'application/json') {
  335. var reader = new FileReader()
  336. reader.addEventListener('loadend', function () {
  337. const obj = JSON.parse(reader.result)
  338. _this.$notification.error({
  339. message: '提示',
  340. description: obj.message
  341. })
  342. })
  343. reader.readAsText(res)
  344. } else {
  345. downloadExcel(res, '散件入库单')
  346. }
  347. })
  348. },
  349. // 供应商下拉数据
  350. getSupplierList () {
  351. supplierAllList().then(res => {
  352. if (res.status == 200) {
  353. this.supplierList = res.data
  354. } else {
  355. this.supplierList = []
  356. }
  357. })
  358. },
  359. pageInit () {
  360. const _this = this
  361. this.$nextTick(() => { // 页面渲染完成后的回调
  362. _this.setTableH()
  363. })
  364. this.openModal = false
  365. this.getSupplierList()
  366. // 是否打开的页签
  367. const a = this.$store.state.app.isNewTab
  368. // 是否要刷新列表
  369. const b = this.$store.state.app.updateList
  370. // 是否从首页点击进入
  371. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  372. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  373. // 从首页进入,判断式新建还式待办查询
  374. if (isHomeNav) {
  375. // 新增
  376. if (isHomeNav.type == 'new') {
  377. this.resetSearchForm()
  378. this.openModal = true
  379. this.setIsHomeNav(this.$route.name, null)
  380. }
  381. // 待办
  382. if (isHomeNav.type == 'todo') {
  383. this.resetData(true)
  384. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  385. this.$refs.table.refresh(true)
  386. }
  387. } else {
  388. // 如果是新页签打开,则重置当前页面
  389. if (a && !b) {
  390. this.resetSearchForm()
  391. }
  392. }
  393. // 仅刷新列表,不重置页面
  394. if (b) {
  395. this.$refs.table.refresh()
  396. }
  397. },
  398. setTableH () {
  399. const tableSearchH = this.$refs.tableSearch.offsetHeight
  400. this.tableHeight = window.innerHeight - tableSearchH - 270
  401. }
  402. },
  403. watch: {
  404. advanced (newValue, oldValue) {
  405. const _this = this
  406. this.$nextTick(() => { // 页面渲染完成后的回调
  407. _this.setTableH()
  408. })
  409. },
  410. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  411. this.setTableH()
  412. }
  413. },
  414. mounted () {},
  415. activated () {
  416. this.pageInit()
  417. },
  418. beforeRouteEnter (to, from, next) {
  419. next(vm => {})
  420. }
  421. }
  422. </script>