list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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" @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: 8px" @click="resetSearchForm()" :disabled="disabled" id="bulkWarehousingOrderList-reset">重置</a-button>
  62. <a-button
  63. style="margin-left: 8px"
  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: 8px">
  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="{ x: 1360, y: tableHeight }"
  102. bordered>
  103. <!-- 散件单号 -->
  104. <template slot="sparePartsPurchaseNo" slot-scope="text, record">
  105. <span v-if="$hasPermissions('B_bulkWarehousingOrder_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.sparePartsPurchaseNo }}</span>
  106. <span v-else>{{ record.sparePartsPurchaseNo }}</span>
  107. </template>
  108. <!-- 操作 -->
  109. <template slot="action" slot-scope="text, record">
  110. <a-button
  111. size="small"
  112. type="link"
  113. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_edit')"
  114. @click="handleEdit(record)"
  115. class="button-info"
  116. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  117. <a-button
  118. size="small"
  119. type="link"
  120. v-if="record.state == 'WAIT_PUT_WAREHOUSE' && $hasPermissions('B_bulkWarehousingOrder_put')"
  121. @click="handleWarehouse(record)"
  122. class="button-primary"
  123. id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
  124. <a-button
  125. size="small"
  126. type="link"
  127. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_del')"
  128. @click="handleDel(record)"
  129. class="button-error"
  130. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  131. <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>
  132. </template>
  133. </s-table>
  134. </a-spin>
  135. <!-- 选择基本信息弹框 -->
  136. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  137. </a-card>
  138. </template>
  139. <script>
  140. import moment from 'moment'
  141. import { STable, VSelect } from '@/components'
  142. import rangeDate from '@/views/common/rangeDate.vue'
  143. import basicInfoModal from './basicInfoModal.vue'
  144. import { sparePartsPurList, sparePartsPurCount, sparePartsPurDel, sparePartsPurPut, sparePartsPurExport } from '@/api/sparePartsPur'
  145. import { supplierAllList } from '@/api/supplier'
  146. export default {
  147. components: { STable, VSelect, basicInfoModal, rangeDate },
  148. data () {
  149. return {
  150. spinning: false,
  151. advanced: true, // 高级搜索 展开/关闭
  152. disabled: false, // 查询、重置按钮是否可操作
  153. exportLoading: false, // 导出loading
  154. openModal: false, // 基本信息弹框是否显示
  155. supplierList: [], // 供应商列表数据
  156. tableHeight: 0,
  157. // 查询参数
  158. queryParam: {
  159. beginDate: '',
  160. endDate: '',
  161. sparePartsPurchaseNo: '', // 散件单号
  162. supplierSn: undefined, // 供应商
  163. state: undefined, // 单据状态
  164. settleState: undefined // 结算状态
  165. },
  166. // 表头
  167. columns: [
  168. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  169. { title: '散件单号', scopedSlots: { customRender: 'sparePartsPurchaseNo' }, width: 220, align: 'center' },
  170. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '供应商', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  172. { title: '产品款数', dataIndex: 'productTotalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  173. { title: '总数量', dataIndex: 'productTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  174. { title: '总金额', dataIndex: 'productTotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  175. { title: '业务状态', dataIndex: 'stateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  176. { title: '财务状态', dataIndex: 'settleStateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  178. ],
  179. // 加载数据方法 必须为 Promise 对象
  180. loadData: parameter => {
  181. this.disabled = true
  182. this.spinning = true
  183. return sparePartsPurList(Object.assign(parameter, this.queryParam)).then(res => {
  184. const data = res.data
  185. const no = (data.pageNo - 1) * data.pageSize
  186. for (var i = 0; i < data.list.length; i++) {
  187. data.list[i].no = no + i + 1
  188. }
  189. this.disabled = false
  190. this.spinning = false
  191. this.dataTotalCount = data.count || 0
  192. this.getTotal(Object.assign(parameter, this.queryParam))
  193. return data
  194. })
  195. },
  196. productTotal: null,
  197. dataTotalCount: 0 // 列表数据总条数
  198. }
  199. },
  200. methods: {
  201. // 时间 change
  202. dateChange (date) {
  203. this.queryParam.beginDate = date[0]
  204. this.queryParam.endDate = date[1]
  205. },
  206. // 合计
  207. getTotal (param) {
  208. sparePartsPurCount(param).then(res => {
  209. if (res.status == 200 && res.data) {
  210. this.productTotal = res.data
  211. } else {
  212. this.productTotal = null
  213. }
  214. })
  215. },
  216. // 新增
  217. handleAdd () {
  218. this.openModal = true
  219. },
  220. // 基本信息 保存
  221. handleOk (row) {
  222. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsPurchaseSn}` })
  223. },
  224. // 编辑
  225. handleEdit (row) {
  226. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsPurchaseSn}` })
  227. },
  228. // 详情
  229. handleDetail (row) {
  230. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
  231. },
  232. // 入库
  233. handleWarehouse (row) {
  234. const _this = this
  235. this.$confirm({
  236. title: '提示',
  237. content: '确定要入库吗?',
  238. centered: true,
  239. onOk () {
  240. _this.spinning = true
  241. sparePartsPurPut({ id: row.id }).then(res => {
  242. if (res.status == 200) {
  243. _this.$message.success(res.message)
  244. _this.$refs.table.refresh()
  245. _this.spinning = false
  246. } else {
  247. _this.spinning = false
  248. }
  249. })
  250. }
  251. })
  252. },
  253. // 删除
  254. handleDel (row) {
  255. const _this = this
  256. this.$confirm({
  257. title: '提示',
  258. content: '删除后不可恢复,确定要进行删除吗?',
  259. centered: true,
  260. onOk () {
  261. _this.spinning = true
  262. sparePartsPurDel({ id: row.id }).then(res => {
  263. if (res.status == 200) {
  264. _this.$message.success(res.message)
  265. _this.$refs.table.refresh()
  266. _this.spinning = false
  267. } else {
  268. _this.spinning = false
  269. }
  270. })
  271. }
  272. })
  273. },
  274. // 重置
  275. resetSearchForm () {
  276. this.$refs.rangeDate.resetDate()
  277. this.queryParam.beginDate = ''
  278. this.queryParam.endDate = ''
  279. this.queryParam.sparePartsPurchaseNo = ''
  280. this.queryParam.supplierSn = undefined
  281. this.queryParam.state = undefined
  282. this.queryParam.settleState = undefined
  283. this.$refs.table.refresh(true)
  284. },
  285. filterOption (input, option) {
  286. return (
  287. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  288. )
  289. },
  290. // 导出
  291. handleExport () {
  292. const _this = this
  293. const params = this.queryParam
  294. this.exportLoading = true
  295. this.spinning = true
  296. sparePartsPurExport(params).then(res => {
  297. this.exportLoading = false
  298. this.spinning = false
  299. if (res.type == 'application/json') {
  300. var reader = new FileReader()
  301. reader.addEventListener('loadend', function () {
  302. const obj = JSON.parse(reader.result)
  303. _this.$notification.error({
  304. message: '提示',
  305. description: obj.message
  306. })
  307. })
  308. reader.readAsText(res)
  309. } else {
  310. this.download(res)
  311. }
  312. })
  313. },
  314. download (data) {
  315. if (!data) { return }
  316. const url = window.URL.createObjectURL(new Blob([data]))
  317. const link = document.createElement('a')
  318. link.style.display = 'none'
  319. link.href = url
  320. const a = moment().format('YYYYMMDDHHmmss')
  321. const fname = '散件入库单' + a
  322. link.setAttribute('download', fname + '.xlsx')
  323. document.body.appendChild(link)
  324. link.click()
  325. },
  326. // 供应商下拉数据
  327. getSupplierList () {
  328. supplierAllList().then(res => {
  329. if (res.status == 200) {
  330. this.supplierList = res.data
  331. } else {
  332. this.supplierList = []
  333. }
  334. })
  335. },
  336. setTableH () {
  337. const tableSearchH = this.$refs.tableSearch.offsetHeight
  338. this.tableHeight = window.innerHeight - tableSearchH - 280
  339. }
  340. },
  341. mounted () {
  342. const _this = this
  343. this.$nextTick(() => { // 页面渲染完成后的回调
  344. _this.setTableH()
  345. })
  346. },
  347. watch: {
  348. advanced (newValue, oldValue) {
  349. const _this = this
  350. setTimeout(() => {
  351. _this.setTableH()
  352. }, 400)
  353. }
  354. },
  355. beforeRouteEnter (to, from, next) {
  356. next(vm => {
  357. vm.openModal = false
  358. vm.getSupplierList()
  359. })
  360. }
  361. }
  362. </script>