list.vue 16 KB

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