list.vue 10 KB

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