list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <a-card size="small" :bordered="false" class="inventoryConfirmationList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 标签页 -->
  5. <a-tabs type="card" :default-active-key="queryParam.state" @change="handleTabChange" class="inventoryConfirmationList-tabs">
  6. <a-tab-pane v-for="item in tabPaneData" :key="item.type">
  7. <span slot="tab">{{ item.name }}</span>
  8. </a-tab-pane>
  9. </a-tabs>
  10. <!-- 搜索条件 -->
  11. <div ref="tableSearch" class="table-page-search-wrapper">
  12. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-item label="盘点单号">
  16. <a-input id="inventoryConfirmationList-checkWarehouseNo" v-model.trim="queryParam.checkWarehouseNo" allowClear placeholder="请输入盘点单号"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryConfirmationList-refresh">查询</a-button>
  21. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryConfirmationList-reset">重置</a-button>
  22. </a-col>
  23. </a-row>
  24. </a-form>
  25. </div>
  26. <!-- 列表 -->
  27. <s-table
  28. class="sTable fixPagination"
  29. ref="table"
  30. :style="{ height: tableHeight+84.5+'px' }"
  31. size="small"
  32. :rowKey="(record) => record.id"
  33. :columns="columns"
  34. :data="loadData"
  35. :scroll="{ y: tableHeight }"
  36. :defaultLoadData="false"
  37. bordered>
  38. <!-- 单号 -->
  39. <template slot="checkWarehouseNo" slot-scope="text, record">
  40. <span :class="$hasPermissions('B_inventoryConfirmationDetail')?'active':'common'" @click="handleDetail(record)">{{ record.checkWarehouseNo }}</span>
  41. </template>
  42. <!-- 操作 -->
  43. <template slot="action" slot-scope="text, record">
  44. <a-button
  45. size="small"
  46. type="link"
  47. class="button-info"
  48. v-if="$hasPermissions('B_inventoryConfirmationConfirm')"
  49. @click="handleConfirm(record)"
  50. id="inventoryConfirmationList-audit-btn">盘点确认</a-button>
  51. <a-button
  52. size="small"
  53. type="link"
  54. class="button-success"
  55. v-if="$hasPermissions('B_inventoryConfirmationCheck')"
  56. @click="handleCheck(record)"
  57. id="inventoryConfirmationList-audit-btn">重新盘点</a-button>
  58. <span v-if="!($hasPermissions('B_inventoryConfirmationConfirm') && $hasPermissions('B_inventoryConfirmationCheck'))">--</span>
  59. </template>
  60. </s-table>
  61. </a-spin>
  62. </a-card>
  63. </template>
  64. <script>
  65. import { STable, VSelect } from '@/components'
  66. import { checkWarehouseList, checkWarehouseReCheck, checkWarehouseFinanceAudit } from '@/api/checkWarehouse'
  67. export default {
  68. components: { STable, VSelect },
  69. data () {
  70. return {
  71. spinning: false,
  72. tableHeight: 0,
  73. queryParam: { // 查询条件
  74. deleteFlag: '0',
  75. state: 'WAIT_FINANCE_AUDIT',
  76. checkWarehouseNo: ''
  77. },
  78. disabled: false, // 查询、重置按钮是否可操作
  79. tabPaneData: [
  80. { name: '未完结', type: 'WAIT_FINANCE_AUDIT' },
  81. { name: '已完结', type: 'FINISH' }
  82. ],
  83. // 加载数据方法 必须为 Promise 对象
  84. loadData: parameter => {
  85. this.disabled = true
  86. this.spinning = true
  87. return checkWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  88. let data
  89. if (res.status == 200) {
  90. data = res.data
  91. const no = (data.pageNo - 1) * data.pageSize
  92. for (var i = 0; i < data.list.length; i++) {
  93. data.list[i].no = no + i + 1
  94. }
  95. this.disabled = false
  96. }
  97. this.spinning = false
  98. return data
  99. })
  100. }
  101. }
  102. },
  103. computed: {
  104. columns () {
  105. let arr = []
  106. if (this.queryParam.state == 'WAIT_FINANCE_AUDIT') { // 未完结
  107. arr = [
  108. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  109. { title: '盘点单号', dataIndex: 'checkWarehouseNo', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '15%', align: 'center' },
  110. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '监盘状态', dataIndex: 'checkSuperviseStateDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '盘点人', dataIndex: 'checkPersonName', align: 'center', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  113. { title: '盘点时间', dataIndex: 'checkTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '监盘人', dataIndex: 'checkSupervisePersonName', align: 'center', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  115. { title: '监盘时间', dataIndex: 'checkSuperviseTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  116. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  117. ]
  118. } else if (this.queryParam.state == 'FINISH') { // 已完结
  119. arr = [
  120. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  121. { title: '盘点单号', dataIndex: 'checkWarehouseNo', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '14%', align: 'center' },
  122. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '监盘状态', dataIndex: 'checkSuperviseStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '盘点人', dataIndex: 'checkPersonName', align: 'center', width: '16%', customRender: function (text) { return text || '--' }, ellipsis: true },
  125. { title: '盘点时间', dataIndex: 'checkTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  126. { title: '监盘人', dataIndex: 'checkSupervisePersonName', align: 'center', width: '16%', customRender: function (text) { return text || '--' }, ellipsis: true },
  127. { title: '监盘时间', dataIndex: 'checkSuperviseTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '财务确认时间', dataIndex: 'financeAuditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  129. ]
  130. }
  131. return arr
  132. }
  133. },
  134. methods: {
  135. // 选择类型
  136. handleTabChange (key) {
  137. this.queryParam.state = key
  138. this.$refs.table.refresh(true)
  139. },
  140. // 详情
  141. handleDetail (row) {
  142. if (this.$hasPermissions('B_inventoryConfirmationDetail')) {
  143. this.$router.push({ path: `/financialManagement/inventoryConfirmation/detail/${row.checkWarehouseSn}` })
  144. }
  145. },
  146. // 盘点确认
  147. handleConfirm (row) {
  148. const _this = this
  149. this.$confirm({
  150. title: '提示',
  151. content: '确认盘点结果正确无误吗?',
  152. centered: true,
  153. closable: true,
  154. onOk () {
  155. _this.spinning = true
  156. checkWarehouseFinanceAudit({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
  157. if (res.status == 200) {
  158. _this.$message.success(res.message)
  159. _this.$refs.table.refresh(true)
  160. _this.spinning = false
  161. } else {
  162. _this.spinning = false
  163. }
  164. })
  165. }
  166. })
  167. },
  168. // 重新盘点
  169. handleCheck (row) {
  170. const _this = this
  171. this.$confirm({
  172. title: '提示',
  173. content: '确认要重新盘点吗?',
  174. centered: true,
  175. closable: true,
  176. onOk () {
  177. _this.spinning = true
  178. checkWarehouseReCheck({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
  179. if (res.status == 200) {
  180. _this.$message.success(res.message)
  181. _this.$refs.table.refresh(true)
  182. _this.spinning = false
  183. } else {
  184. _this.spinning = false
  185. }
  186. })
  187. }
  188. })
  189. },
  190. resetSearchForm () {
  191. this.queryParam.checkWarehouseNo = ''
  192. this.$refs.table.refresh(true)
  193. },
  194. pageInit () {
  195. const _this = this
  196. this.$nextTick(() => { // 页面渲染完成后的回调
  197. _this.setTableH()
  198. })
  199. },
  200. setTableH () {
  201. this.tableHeight = window.innerHeight - 295
  202. }
  203. },
  204. watch: {
  205. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  206. this.setTableH()
  207. }
  208. },
  209. mounted () {
  210. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  211. this.pageInit()
  212. this.$refs.table.refresh(true)
  213. }
  214. },
  215. activated () {
  216. // 如果是新页签打开,则重置当前页面
  217. if (this.$store.state.app.isNewTab) {
  218. this.pageInit()
  219. this.$refs.table.refresh(true)
  220. }
  221. // 仅刷新列表,不重置页面
  222. if (this.$store.state.app.updateList) {
  223. this.pageInit()
  224. this.$refs.table.refresh()
  225. }
  226. },
  227. beforeRouteEnter (to, from, next) {
  228. next(vm => {})
  229. }
  230. }
  231. </script>
  232. <style lang="less">
  233. .inventoryConfirmationList-wrap{
  234. .active{
  235. color: #ed1c24;
  236. cursor: pointer;
  237. }
  238. .common{
  239. color: rgba(0, 0, 0);
  240. }
  241. // tab样式
  242. .inventoryConfirmationList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-nav-container{
  243. height: 30px!important;
  244. }
  245. .inventoryConfirmationList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active{
  246. height: 30px!important;
  247. }
  248. .inventoryConfirmationList-tabs.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab{
  249. line-height: 26px!important;
  250. height: 30px!important;
  251. }
  252. }
  253. </style>