list.vue 11 KB

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