list.vue 11 KB

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