list.vue 11 KB

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