list.vue 15 KB

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