list.vue 11 KB

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