list.vue 11 KB

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