list.vue 12 KB

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