list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBox">
  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. <a-input id="bulkWarehousingOrderList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="关联单号">
  15. <a-input id="bulkWarehousingOrderList-relationNo" v-model.trim="queryParam.relationNo" allowClear placeholder="请输入关联单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="入库单号">
  20. <a-input id="bulkWarehousingOrderList-sparePartsNo" v-model.trim="queryParam.sparePartsNo" allowClear placeholder="请输入入库单号"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="商户名称">
  25. <a-input id="bulkWarehousingOrderList-supplierName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入商户名称"/>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="金蝶单号">
  31. <a-input id="bulkWarehousingOrderList-kingdeeNo" v-model.trim="queryParam.kingdeeNo" allowClear placeholder="请输入金蝶单号"/>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="入库类型">
  36. <v-select
  37. v-model="queryParam.sparePartsType"
  38. ref="sparePartsType"
  39. id="bulkWarehousingOrderList-sparePartsType"
  40. code="SPARE_PARTS_TYPE"
  41. placeholder="请选择入库类型"
  42. allowClear></v-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24" v-show="isShowWarehouse">
  46. <a-form-item label="入库仓库">
  47. <warehouse
  48. v-model="queryParam.warehouseSn"
  49. isPermission
  50. id="salesReturn-warehouseSn"
  51. placeholder="请选择入库仓库"
  52. />
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="状态">
  57. <v-select
  58. v-model="queryParam.state"
  59. ref="state"
  60. id="bulkWarehousingOrderList-state"
  61. code="SPARE_PARTS_STATE"
  62. placeholder="请选择状态"
  63. allowClear
  64. ></v-select>
  65. </a-form-item>
  66. </a-col>
  67. </template>
  68. <a-col :md="24" :sm="24" style="text-align: center;">
  69. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderList-refresh">查询</a-button>
  70. <a-button style="margin-left: 10px" @click="resetSearchForm()" :disabled="disabled" id="bulkWarehousingOrderList-reset">重置</a-button>
  71. <a-button
  72. style="margin-left: 10px"
  73. v-if="$hasPermissions('B_sparePartsExport')"
  74. type="primary"
  75. class="button-warning"
  76. @click="handleExport"
  77. :disabled="disabled"
  78. :loading="exportLoading"
  79. >导出明细</a-button>
  80. <a @click="advanced=!advanced" style="margin-left: 8px">
  81. {{ advanced ? '收起' : '展开' }}
  82. <a-icon :type="advanced ? 'up' : 'down'"/>
  83. </a>
  84. </a-col>
  85. </a-row>
  86. </a-form>
  87. </div>
  88. </a-card>
  89. <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-wrap">
  90. <a-spin :spinning="spinning" tip="Loading...">
  91. <!-- 操作按钮 -->
  92. <div class="table-operator">
  93. <a-button v-if="$hasPermissions('B_sparePartsNew')" id="bulkWarehousingOrderList-add" type="primary" @click="handleAdd">新增</a-button>
  94. <a-button
  95. v-if="$hasPermissions('B_sparePartsBatchAudit')"
  96. id="bulkWarehousingOrderList-batchAudit"
  97. type="primary"
  98. class="button-warning"
  99. :loading="loading"
  100. @click="handleBatchAudit"
  101. style="margin: 0 3px;">批量审核</a-button>
  102. <span style="margin-left: 10px">
  103. <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}</template>
  104. </span>
  105. </div>
  106. <!-- 列表 -->
  107. <s-table
  108. class="sTable fixPagination"
  109. ref="table"
  110. :style="{ height: tableHeight+70+'px' }"
  111. size="small"
  112. :rowKey="(record) => record.sparePartsSn"
  113. rowKeyName="sparePartsSn"
  114. :row-selection="$hasPermissions('B_sparePartsBatchAudit')?{ columnWidth: '4%', getCheckboxProps: record => ({ props: { disabled: record.state != 'WAIT_AUDIT' } }) }:null"
  115. @rowSelection="rowSelectionFun"
  116. :columns="columns"
  117. :pageSize="30"
  118. :data="loadData"
  119. :scroll="{ y: tableHeight }"
  120. :defaultLoadData="false"
  121. bordered>
  122. <!-- 入库单号 -->
  123. <template slot="sparePartsNo" slot-scope="text, record">
  124. <span v-if="$hasPermissions('B_sparePartsDetail')" class="link-bule" @click="handleDetail(record)">{{ record.sparePartsNo }}</span>
  125. <span v-else>{{ record.sparePartsNo }}</span>
  126. </template>
  127. <!-- 操作 -->
  128. <template slot="action" slot-scope="text, record">
  129. <a-button
  130. size="small"
  131. type="link"
  132. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsAudit')"
  133. class="button-warning"
  134. @click="handleAudit(record)"
  135. id="allocateBillList-examine-btn">审核</a-button>
  136. <a-button
  137. size="small"
  138. type="link"
  139. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsEdit')"
  140. @click="handleEdit(record)"
  141. class="button-info"
  142. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  143. <a-button
  144. size="small"
  145. type="link"
  146. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsDel')"
  147. @click="handleDel(record)"
  148. class="button-error"
  149. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  150. <span v-if="!(record.state == 'WAIT_AUDIT'&&($hasPermissions('B_sparePartsEdit') || $hasPermissions('B_sparePartsDel') || $hasPermissions('B_sparePartsAudit')))">--</span>
  151. </template>
  152. </s-table>
  153. </a-spin>
  154. <!-- 选择基本信息弹框 -->
  155. <basic-info-modal v-drag :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  156. <sparePartsDetailModal v-drag :openModal="openDetailModal" :itemSn="itemSn" @close="closeDetailModal" />
  157. <!-- 导出提示框 -->
  158. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  159. <!-- 审核不通过弹框 -->
  160. <auditNoPassModal v-drag ref="auditNoPassModal" :openModal="openAuditNoModal" @close="openAuditNoModal=false" />
  161. <batchAuditNoModal v-drag ref="batchAuditNoModal" :openModal="openBatchAuditNoModal" @close="openBatchAuditNoModal=false" @ok="hanldeAuditOk" />
  162. </a-card>
  163. </div>
  164. </template>
  165. <script>
  166. import { commonMixin } from '@/utils/mixin'
  167. import { STable, VSelect } from '@/components'
  168. import basicInfoModal from './basicInfoModal.vue'
  169. import warehouse from '@/views/common/chooseWarehouse.js'
  170. import sparePartsDetailModal from './detailModal.vue'
  171. import reportModal from '@/views/common/reportModal.vue'
  172. import auditNoPassModal from './auditNoPassModal.vue'
  173. import batchAuditNoModal from './batchAuditNoModal.vue'
  174. import { hdExportExcel } from '@/libs/exportExcel'
  175. import { sparePartsList, sparePartsDelete, sparePartsAudit, sparePartsAuditVerify, sparePartsDetailExport } from '@/api/spareParts'
  176. export default {
  177. name: 'BulkWarehousingOrderList',
  178. mixins: [commonMixin],
  179. components: { STable, VSelect, basicInfoModal, sparePartsDetailModal, reportModal, auditNoPassModal, batchAuditNoModal, warehouse },
  180. data () {
  181. return {
  182. spinning: false,
  183. disabled: false, // 查询、重置按钮是否可操作
  184. openModal: false, // 基本信息弹框是否显示
  185. showExport: false,
  186. exportLoading: false,
  187. openAuditNoModal: false,
  188. openBatchAuditNoModal: false,
  189. advanced: true,
  190. tableHeight: 0,
  191. // 查询参数
  192. queryParam: {
  193. productCode: '',
  194. relationNo: '',
  195. state: undefined,
  196. sparePartsType: undefined,
  197. warehouseSn: undefined,
  198. sparePartsNo: '',
  199. supplierName: '',
  200. kingdeeNo: ''
  201. },
  202. loading: false,
  203. // 加载数据方法 必须为 Promise 对象
  204. loadData: parameter => {
  205. this.disabled = true
  206. this.spinning = true
  207. return sparePartsList(Object.assign(parameter, this.queryParam)).then(res => {
  208. let data
  209. if (res.status == 200) {
  210. data = res.data
  211. const no = (data.pageNo - 1) * data.pageSize
  212. for (var i = 0; i < data.list.length; i++) {
  213. data.list[i].no = no + i + 1
  214. }
  215. this.disabled = false
  216. }
  217. this.spinning = false
  218. return data
  219. })
  220. },
  221. openDetailModal: false,
  222. itemSn: null,
  223. rowSelectionInfo: null
  224. }
  225. },
  226. computed: {
  227. columns () {
  228. const arr = [
  229. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  230. { title: '入库单号', scopedSlots: { customRender: 'sparePartsNo' }, width: '8%', align: 'center' },
  231. { title: '商户名称', dataIndex: 'supplierName', align: 'left', width: '12%', customRender: function (text) { return text || '--' }, ellipsis: true },
  232. { title: '入库数量', dataIndex: 'productTotalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  233. // { title: '入库成本', dataIndex: 'productTotalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  234. { title: '入库类型', dataIndex: 'sparePartsTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  235. // { title: '入库仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '关联单号', dataIndex: 'relationNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  237. { title: '金蝶单号', dataIndex: 'kingdeeNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '备注', dataIndex: 'remark', width: '9%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  240. { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  241. ]
  242. if (this.$hasPermissions('M_bulkWarehousingOrderList_costPrice')) { // 成本价权限
  243. arr.splice(4, 0, { title: '入库成本', dataIndex: 'productTotalCost', width: '6%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  244. }
  245. if (this.isShowWarehouse) {
  246. arr.splice(this.$hasPermissions('M_bulkWarehousingOrderList_costPrice')?6:5, 0, { title: '入库仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } })
  247. }
  248. return arr
  249. }
  250. },
  251. methods: {
  252. // 表格选中项
  253. rowSelectionFun (obj) {
  254. this.rowSelectionInfo = obj || null
  255. },
  256. // 导出
  257. handleExport () {
  258. const _this = this
  259. this.$store.state.app.curActionPermission = 'B_sparePartsExport'
  260. _this.exportLoading = true
  261. _this.spinning = true
  262. hdExportExcel(sparePartsDetailExport, _this.queryParam , '散件入库明细', function () {
  263. _this.exportLoading = false
  264. _this.spinning = false
  265. _this.showExport = true
  266. _this.$store.state.app.curActionPermission = ''
  267. })
  268. },
  269. // 新增
  270. handleAdd () {
  271. this.openModal = true
  272. },
  273. // 基本信息 保存
  274. handleOk (row) {
  275. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsSn}` })
  276. },
  277. // 编辑
  278. handleEdit (row) {
  279. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsSn}` })
  280. },
  281. // 详情
  282. handleDetail (row) {
  283. if (!this.$hasPermissions('B_sparePartsDetail')) { return }
  284. this.itemSn = row.sparePartsSn
  285. this.openDetailModal = true
  286. },
  287. // 关闭弹框
  288. closeDetailModal () {
  289. this.itemSn = null
  290. this.openDetailModal = false
  291. },
  292. // 删除
  293. handleDel (row) {
  294. const _this = this
  295. this.$confirm({
  296. title: '提示',
  297. content: '删除后不可恢复,确定要进行删除吗?',
  298. centered: true,
  299. onOk () {
  300. _this.spinning = true
  301. sparePartsDelete({ sn: row.sparePartsSn }).then(res => {
  302. if (res.status == 200) {
  303. _this.$message.success(res.message)
  304. _this.$refs.table.refresh()
  305. _this.spinning = false
  306. } else {
  307. _this.spinning = false
  308. }
  309. })
  310. }
  311. })
  312. },
  313. // 重置
  314. resetSearchForm () {
  315. this.queryParam = {
  316. productCode: '',
  317. relationNo: '',
  318. state: undefined,
  319. sparePartsType: undefined,
  320. warehouseSn: undefined, // 仓库
  321. sparePartsNo: '',
  322. supplierName: '',
  323. kingdeeNo: ''
  324. }
  325. this.$refs.table.refresh(true)
  326. this.$refs.table.clearSelected()
  327. },
  328. // 单条审核
  329. handleAudit (row) {
  330. const _this = this
  331. this.$confirm({
  332. title: '提示',
  333. content: '确认要审核通过吗?',
  334. centered: true,
  335. onOk () {
  336. _this.spinning = true
  337. sparePartsAudit({ sn: row.sparePartsSn }).then(res => {
  338. if (res.status == 200) {
  339. if (res.data && res.data.sparePartsDetailList) {
  340. _this.$nextTick(() => {
  341. _this.openAuditNoModal = true
  342. _this.$refs.auditNoPassModal.setData(res.data.sparePartsDetailList)
  343. })
  344. } else {
  345. _this.hanldeAuditOk(res.message)
  346. }
  347. }
  348. _this.spinning = false
  349. })
  350. }
  351. })
  352. },
  353. // 批量审核
  354. handleBatchAudit () {
  355. const _this = this
  356. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  357. this.$message.warning('请在列表勾选后再进行批量操作!')
  358. return
  359. }
  360. const snList = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys || []
  361. _this.spinning = true
  362. sparePartsAuditVerify(snList).then(res => {
  363. if (res.status == 200 && res.data) {
  364. _this.$nextTick(() => {
  365. _this.openBatchAuditNoModal = true
  366. _this.$refs.batchAuditNoModal.getData(res.data)
  367. })
  368. }
  369. _this.spinning = false
  370. })
  371. },
  372. // 审核成功
  373. hanldeAuditOk (message) {
  374. this.$refs.table.clearSelected() // 清空表格选中项
  375. this.$message.success(message)
  376. this.$refs.table.refresh()
  377. },
  378. pageInit () {
  379. const _this = this
  380. this.$nextTick(() => { // 页面渲染完成后的回调
  381. _this.setTableH()
  382. })
  383. this.openModal = false
  384. this.openDetailModal = false
  385. this.itemSn = null
  386. this.rowSelectionInfo = null
  387. this.$refs.table.clearTable()
  388. },
  389. setTableH () {
  390. const tableSearchH = this.$refs.tableSearch.offsetHeight
  391. this.tableHeight = window.innerHeight - tableSearchH - 250
  392. }
  393. },
  394. watch: {
  395. advanced (newValue, oldValue) {
  396. const _this = this
  397. this.$nextTick(() => { // 页面渲染完成后的回调
  398. _this.setTableH()
  399. })
  400. },
  401. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  402. this.setTableH()
  403. }
  404. },
  405. mounted () {
  406. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  407. this.pageInit()
  408. this.resetSearchForm()
  409. }
  410. },
  411. activated () {
  412. // 如果是新页签打开,则重置当前页面
  413. if (this.$store.state.app.isNewTab) {
  414. this.pageInit()
  415. this.resetSearchForm()
  416. }
  417. // 仅刷新列表,不重置页面
  418. if (this.$store.state.app.updateList) {
  419. this.pageInit()
  420. this.$refs.table.refresh()
  421. }
  422. },
  423. beforeRouteEnter (to, from, next) {
  424. next(vm => {})
  425. }
  426. }
  427. </script>