list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div 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" style="margin-top: 3px;">
  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" showIcon style="margin-bottom:15px">
  86. <div slot="message">共 <strong>{{ dataTotalCount }}</strong> 条记录,总数量合计 <strong>{{ productTotal.productTotalQty }}</strong> ,总金额合计¥<strong>{{ productTotal.productTotalCost }}</strong> </div>
  87. </a-alert>
  88. <!-- 列表 -->
  89. <s-table
  90. class="sTable"
  91. ref="table"
  92. size="default"
  93. :rowKey="(record) => record.id"
  94. :columns="columns"
  95. :data="loadData"
  96. :scroll="{ x: 1360, y: tableHeight }"
  97. bordered>
  98. <!-- 散件单号 -->
  99. <template slot="sparePartsPurchaseNo" slot-scope="text, record">
  100. <span v-if="$hasPermissions('B_bulkWarehousingOrder_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.sparePartsPurchaseNo }}</span>
  101. <span v-else>{{ record.sparePartsPurchaseNo }}</span>
  102. </template>
  103. <!-- 财务状态 -->
  104. <template slot="settleState" slot-scope="text, record">
  105. <a-badge :color="text=='FINISH'?'#87d068':'gold'" :text="record.settleStateDictValue" />
  106. </template>
  107. <!-- 操作 -->
  108. <template slot="action" slot-scope="text, record">
  109. <a-button
  110. size="small"
  111. type="link"
  112. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_edit')"
  113. @click="handleEdit(record)"
  114. class="button-info"
  115. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  116. <a-button
  117. size="small"
  118. type="link"
  119. v-if="record.state == 'WAIT_PUT_WAREHOUSE' && $hasPermissions('B_bulkWarehousingOrder_put')"
  120. @click="handleWarehouse(record)"
  121. class="button-primary"
  122. id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
  123. <a-button
  124. size="small"
  125. type="link"
  126. v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_del')"
  127. @click="handleDel(record)"
  128. class="button-error"
  129. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  130. <!-- <span v-if="record.state == 'FINISH' && record.state != 'WAIT_PUT_WAREHOUSE'">--</span> -->
  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: false, // 高级搜索 展开/关闭
  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' },
  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' },
  176. { title: '财务状态', dataIndex: 'settleState', scopedSlots: { customRender: 'settleState' }, width: 100, align: 'center' },
  177. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  178. ],
  179. // 加载数据方法 必须为 Promise 对象
  180. loadData: parameter => {
  181. this.disabled = true
  182. if (this.tableHeight == 0) {
  183. this.tableHeight = window.innerHeight - 440
  184. }
  185. return sparePartsPurList(Object.assign(parameter, this.queryParam)).then(res => {
  186. const data = res.data
  187. const no = (data.pageNo - 1) * data.pageSize
  188. for (var i = 0; i < data.list.length; i++) {
  189. data.list[i].no = no + i + 1
  190. }
  191. this.disabled = false
  192. this.dataTotalCount = data.count
  193. this.getTotal(Object.assign(parameter, this.queryParam))
  194. return data
  195. })
  196. },
  197. productTotal: { // 合计信息
  198. productTotalCost: '',
  199. productTotalQty: ''
  200. },
  201. dataTotalCount: '' // 列表数据总条数
  202. }
  203. },
  204. methods: {
  205. // 时间 change
  206. dateChange (date) {
  207. this.queryParam.beginDate = date[0]
  208. this.queryParam.endDate = date[1]
  209. },
  210. // 合计
  211. getTotal (param) {
  212. sparePartsPurCount(param).then(res => {
  213. if (res.status == 200 && res.data) {
  214. this.productTotal = res.data
  215. } else {
  216. this.productTotal = {
  217. // 合计信息
  218. productTotalCost: '',
  219. productTotalQty: ''
  220. }
  221. }
  222. })
  223. },
  224. // 新增
  225. handleAdd () {
  226. this.openModal = true
  227. },
  228. // 基本信息 保存
  229. handleOk (row) {
  230. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsPurchaseSn}` })
  231. },
  232. // 编辑
  233. handleEdit (row) {
  234. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsPurchaseSn}` })
  235. },
  236. // 详情
  237. handleDetail (row) {
  238. this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
  239. },
  240. // 入库
  241. handleWarehouse (row) {
  242. const _this = this
  243. this.$confirm({
  244. title: '提示',
  245. content: '确定要入库吗?',
  246. centered: true,
  247. onOk () {
  248. _this.spinning = true
  249. sparePartsPurPut({ id: row.id }).then(res => {
  250. if (res.status == 200) {
  251. _this.$message.success(res.message)
  252. _this.$refs.table.refresh()
  253. _this.spinning = false
  254. } else {
  255. _this.spinning = false
  256. }
  257. })
  258. }
  259. })
  260. },
  261. // 删除
  262. handleDel (row) {
  263. const _this = this
  264. this.$confirm({
  265. title: '提示',
  266. content: '删除后不可恢复,确定要进行删除吗?',
  267. centered: true,
  268. onOk () {
  269. _this.spinning = true
  270. sparePartsPurDel({ id: row.id }).then(res => {
  271. if (res.status == 200) {
  272. _this.$message.success(res.message)
  273. _this.$refs.table.refresh()
  274. _this.spinning = false
  275. } else {
  276. _this.spinning = false
  277. }
  278. })
  279. }
  280. })
  281. },
  282. // 重置
  283. resetSearchForm () {
  284. this.$refs.rangeDate.resetDate()
  285. this.queryParam.beginDate = ''
  286. this.queryParam.endDate = ''
  287. this.queryParam.sparePartsPurchaseNo = ''
  288. this.queryParam.supplierSn = undefined
  289. this.queryParam.state = undefined
  290. this.queryParam.settleState = undefined
  291. this.$refs.table.refresh(true)
  292. },
  293. filterOption (input, option) {
  294. return (
  295. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  296. )
  297. },
  298. // 导出
  299. handleExport () {
  300. const _this = this
  301. const params = this.queryParam
  302. this.exportLoading = true
  303. this.spinning = true
  304. sparePartsPurExport(params).then(res => {
  305. this.exportLoading = false
  306. this.spinning = false
  307. if (res.type == 'application/json') {
  308. var reader = new FileReader()
  309. reader.addEventListener('loadend', function () {
  310. const obj = JSON.parse(reader.result)
  311. _this.$notification.error({
  312. message: '提示',
  313. description: obj.message
  314. })
  315. })
  316. reader.readAsText(res)
  317. } else {
  318. this.download(res)
  319. }
  320. })
  321. },
  322. download (data) {
  323. if (!data) { return }
  324. const url = window.URL.createObjectURL(new Blob([data]))
  325. const link = document.createElement('a')
  326. link.style.display = 'none'
  327. link.href = url
  328. const a = moment().format('YYYYMMDDHHmmss')
  329. const fname = '散件入库单' + a
  330. link.setAttribute('download', fname + '.xlsx')
  331. document.body.appendChild(link)
  332. link.click()
  333. },
  334. // 供应商下拉数据
  335. getSupplierList () {
  336. supplierAllList().then(res => {
  337. if (res.status == 200) {
  338. this.supplierList = res.data
  339. } else {
  340. this.supplierList = []
  341. }
  342. })
  343. }
  344. },
  345. beforeRouteEnter (to, from, next) {
  346. next(vm => {
  347. vm.openModal = false
  348. vm.getSupplierList()
  349. })
  350. }
  351. }
  352. </script>
  353. <style lang="less">
  354. .bulkWarehousingOrderList-wrap{
  355. .sTable{
  356. margin-top: 15px;
  357. }
  358. }
  359. </style>