list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  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="warehousingConfirmationList-stockPutNo" v-model.trim="queryParam.stockPutNo" 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="warehousingConfirmationList-putBizNo" v-model.trim="queryParam.putBizNo" allowClear placeholder="请输入业务单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="入库类型">
  20. <v-select
  21. v-model="queryParam.putBizType"
  22. id="warehousingConfirmationList-putBizType"
  23. code="PUT_STOCK_TYPE"
  24. placeholder="请选择入库类型"
  25. allowClear></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="单据状态">
  30. <v-select
  31. v-model="queryParam.auditState"
  32. ref="auditState"
  33. id="warehousingConfirmationList-auditState"
  34. code="PUT_CONFIRM_STATE"
  35. placeholder="请选择单据状态"
  36. allowClear></v-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24" v-show="isShowWarehouse">
  40. <a-form-model-item label="仓库">
  41. <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn" :isPermission="true"></chooseWarehouse>
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :md="isShowWarehouse?6:24" :sm="24" style="margin-bottom: 10px;" :style="{textAlign:isShowWarehouse?'left':'center'}">
  45. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehousingConfirmationList-refresh">查询</a-button>
  46. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="warehousingConfirmationList-reset">重置</a-button>
  47. </a-col>
  48. </a-row>
  49. </a-form>
  50. </div>
  51. </a-card>
  52. <a-card size="small" :bordered="false" class="warehousingConfirmationList-wrap">
  53. <a-spin :spinning="spinning" tip="Loading...">
  54. <!-- 列表 -->
  55. <div v-if="$hasPermissions('B_warehousingConfirmationpl')" style="margin-bottom: 10px">
  56. <a-button type="primary" id="warehousingConfirmationList-export" :loading="loading" @click="handleBatchAudit">批量确认</a-button>
  57. <span style="margin-left: 10px">
  58. <template v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length>0"> {{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }} </template>
  59. </span>
  60. </div>
  61. <s-table
  62. class="sTable fixPagination"
  63. ref="table"
  64. :style="{ height: tableHeight+70+'px' }"
  65. size="small"
  66. :rowKey="(record) => record.stockPutSn"
  67. rowKeyName="stockPutSn"
  68. :row-selection="$hasPermissions('B_warehousingConfirmationpl') ? { columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.auditState != 'WAIT' } }) } : null"
  69. @rowSelection="rowSelectionFun"
  70. :columns="columns"
  71. :data="loadData"
  72. :pageSize="30"
  73. :scroll="{ y: tableHeight }"
  74. :defaultLoadData="false"
  75. bordered>
  76. <!-- 入库单号 -->
  77. <template slot="stockPutNo" slot-scope="text, record">
  78. <span :id="'warehousingConfirmationList-detail-'+record.stockPutNo" v-if="$hasPermissions('B_warehousingConfirmationDetail')" class="link-bule" @click="handleDetail(record)">{{ record.stockPutNo }}</span>
  79. <span v-else>{{ record.stockPutNo }}</span>
  80. </template>
  81. <!-- 操作 -->
  82. <template slot="action" slot-scope="text, record">
  83. <a-button
  84. size="small"
  85. type="link"
  86. v-if="record.auditState=='WAIT' && $hasPermissions('B_warehousingConfirmationAlone')"
  87. class="button-info"
  88. @click="handleAudit(record)"
  89. :id="'warehousingConfirmationList-audit-btn-'+record.stockPutNo">入库确认</a-button>
  90. <span v-else>--</span>
  91. </template>
  92. </s-table>
  93. </a-spin>
  94. <!-- 查看 -->
  95. <confirmation-detail-modal v-drag :openModal="openModal" :itemSn="itemSn" :nowData="nowData" @close="closeModal" />
  96. <!-- 入库确认 -->
  97. <a-modal
  98. centered
  99. v-drag
  100. class="confirmation-modal"
  101. :footer="null"
  102. :maskClosable="false"
  103. v-model="confirmationModal"
  104. @cancel="confirmationModal=false"
  105. :width="416">
  106. <div class="confirmation-main">
  107. <a-icon type="question-circle" style="color: #faad14;font-size: 22px;margin-right: 16px;" />
  108. <div class="confirmation-cont">
  109. <p class="confirmation-tit">提示</p>
  110. <p class="confirmation-txt">请点击下方按钮确认操作?</p>
  111. </div>
  112. </div>
  113. <div class="btn-box">
  114. <a-button
  115. v-if="confirmationInfo&&confirmationInfo.putBizType!='PURCHASE'"
  116. id="confir-ruku-cancel"
  117. type="primary"
  118. :loading="spinning"
  119. class="button-error"
  120. @click="handleConfirmationFail">不通过</a-button>
  121. <a-button id="confir-ruku-ok" type="primary" :loading="spinning" class="button-info" @click="handleConfirmationOk">通过</a-button>
  122. </div>
  123. </a-modal>
  124. </a-card>
  125. </div>
  126. </template>
  127. <script>
  128. import { commonMixin } from '@/utils/mixin'
  129. import { STable, VSelect } from '@/components'
  130. import confirmationDetailModal from './detailModal.vue'
  131. import chooseWarehouse from '@/views/common/chooseWarehouse'
  132. import { stockPutList, stockPutConfirm } from '@/api/stockPut'
  133. export default {
  134. name: 'WarehousingConfirmationList',
  135. mixins: [commonMixin],
  136. components: { STable, VSelect, confirmationDetailModal, chooseWarehouse },
  137. data () {
  138. return {
  139. spinning: false,
  140. loading: false,
  141. queryParam: { // 查询条件
  142. stockPutNo: '', // 入库单号
  143. putBizNo: '', // 业务单号
  144. putBizType: undefined, // 入库类型
  145. auditState: undefined, // 状态
  146. warehouseSn: undefined // 仓库
  147. },
  148. tableHeight: 0, // 表格高度
  149. disabled: false, // 查询、重置按钮是否可操作
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. this.disabled = true
  153. this.spinning = true
  154. return stockPutList(Object.assign(parameter, this.queryParam, { confirm: true })).then(res => {
  155. let data
  156. if (res.status == 200) {
  157. data = res.data
  158. this.disabled = false
  159. }
  160. this.spinning = false
  161. return data
  162. })
  163. },
  164. openModal: false, // 详情弹框
  165. itemSn: '', // 详情弹框单据sn
  166. nowData: null, // 详情弹框当前操作数据
  167. confirmationModal: false, // 入库确认弹框
  168. confirmationInfo: null, // 确认入库得单据数据
  169. isBatch: false, // 是否批量确认入库
  170. rowSelectionInfo: null // 批量操作已选数据
  171. }
  172. },
  173. computed: {
  174. // 列表表头
  175. columns () {
  176. const arr = [
  177. { title: '入库时间', dataIndex: 'putTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  178. { title: '入库单号', scopedSlots: { customRender: 'stockPutNo' }, width: '12%', align: 'center' },
  179. { title: '业务单号', dataIndex: 'putBizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  180. { title: '商户名称', dataIndex: 'providerName', align: 'left', width: '18%', customRender: function (text) { return text || '--' }, ellipsis: true },
  181. { title: '入库数量', dataIndex: 'productTotalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  182. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '单据状态', dataIndex: 'auditStateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '财务审核时间', dataIndex: 'auditTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '备注', dataIndex: 'remark', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  186. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  187. ]
  188. // 是否显示仓库
  189. if (this.isShowWarehouse) {
  190. arr.splice(3, 0, { title: '仓库', dataIndex: 'warehouseName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  191. }
  192. if (this.$hasPermissions('M_warehousingConfirmationList_costPrice')) { // 成本价权限
  193. arr.splice(this.isShowWarehouse ? 5 : 4, 0, { title: '入库成本', dataIndex: 'productTotalCost', width: '7%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  194. }
  195. return arr
  196. }
  197. },
  198. methods: {
  199. // 表格选中项
  200. rowSelectionFun (obj) {
  201. this.rowSelectionInfo = obj || null
  202. },
  203. // 重置
  204. resetSearchForm () {
  205. this.queryParam.stockPutNo = ''
  206. this.queryParam.putBizNo = ''
  207. this.queryParam.putBizType = undefined
  208. this.queryParam.auditState = undefined
  209. this.queryParam.warehouseSn = undefined
  210. this.$refs.table.refresh(true)
  211. },
  212. // 详情
  213. handleDetail (row) {
  214. if (this.$hasPermissions('B_warehousingConfirmationDetail')) {
  215. this.itemSn = row.stockPutSn
  216. this.nowData = row
  217. this.openModal = true
  218. }
  219. },
  220. // 关闭详情弹框
  221. closeModal () {
  222. this.itemSn = ''
  223. this.nowData = null
  224. this.openModal = false
  225. },
  226. // 入库确认通过
  227. handleConfirmationOk () {
  228. if (this.isBatch) { // 批量
  229. this.auditOrder(this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys, true)
  230. } else {
  231. this.auditOrder([this.confirmationInfo.stockPutSn], true)
  232. }
  233. },
  234. // 入库确认不通过
  235. handleConfirmationFail () {
  236. if (this.isBatch) { // 批量
  237. this.auditOrder(this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys, false)
  238. } else {
  239. this.auditOrder([this.confirmationInfo.stockPutSn], false)
  240. }
  241. },
  242. // 打开入库确认
  243. handleAudit (row) {
  244. this.confirmationInfo = row
  245. this.isBatch = false
  246. this.confirmationModal = true
  247. },
  248. // 入库确认接口调用
  249. auditOrder (snList, flag) {
  250. const _this = this
  251. if (this.isBatch) {
  252. _this.loading = true
  253. }
  254. _this.spinning = true
  255. stockPutConfirm({ stockPutSnList: snList, confirm: flag }).then(res => {
  256. if (this.isBatch) {
  257. _this.loading = false
  258. }
  259. if (res.status == 200) {
  260. if (this.isBatch) {
  261. _this.$refs.table.clearSelected() // 清空表格选中项
  262. }
  263. _this.$message.success(res.message)
  264. _this.$refs.table.refresh()
  265. _this.confirmationModal = false
  266. _this.spinning = false
  267. } else {
  268. _this.confirmationModal = false
  269. _this.spinning = false
  270. }
  271. })
  272. },
  273. // 批量入库确认
  274. handleBatchAudit () {
  275. const _this = this
  276. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  277. _this.$message.warning('请在列表勾选后再进行批量操作!')
  278. return
  279. }
  280. this.isBatch = true
  281. this.confirmationModal = true
  282. },
  283. // 页面初始
  284. pageInit () {
  285. const _this = this
  286. this.$nextTick(() => { // 页面渲染完成后的回调
  287. _this.setTableH()
  288. })
  289. this.rowSelectionInfo = null
  290. this.$refs.table.clearTable()
  291. },
  292. // 表格高度
  293. setTableH () {
  294. const tableSearchH = this.$refs.tableSearch.offsetHeight
  295. this.tableHeight = window.innerHeight - tableSearchH - 240
  296. }
  297. },
  298. watch: {
  299. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  300. this.setTableH()
  301. }
  302. },
  303. mounted () {
  304. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  305. this.pageInit()
  306. this.resetSearchForm()
  307. }
  308. },
  309. activated () {
  310. // 如果是新页签打开,则重置当前页面
  311. if (this.$store.state.app.isNewTab) {
  312. this.pageInit()
  313. this.resetSearchForm()
  314. }
  315. // 仅刷新列表,不重置页面
  316. if (this.$store.state.app.updateList) {
  317. this.pageInit()
  318. this.$refs.table.refresh()
  319. }
  320. },
  321. beforeRouteEnter (to, from, next) {
  322. next(vm => {})
  323. }
  324. }
  325. </script>
  326. <style lang="less">
  327. .active{
  328. color: #ed1c24;
  329. cursor: pointer;
  330. }
  331. .common{
  332. color: rgba(0, 0, 0);
  333. }
  334. .confirmation-modal{
  335. .ant-modal-body{
  336. padding: 32px 32px 24px;
  337. }
  338. .confirmation-main{
  339. display: flex;
  340. .confirmation-cont{
  341. .confirmation-tit{
  342. color: rgba(0, 0, 0);
  343. font-weight: 500;
  344. font-size: 16px;
  345. line-height: 1.4;
  346. margin: 0;
  347. }
  348. .confirmation-txt{
  349. margin: 8px 0 0;
  350. color: rgba(0, 0, 0);
  351. font-size: 14px;
  352. line-height: 1.5;
  353. }
  354. }
  355. }
  356. .btn-box{
  357. text-align: right;
  358. margin-top: 24px;
  359. }
  360. }
  361. </style>