list.vue 12 KB

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