list.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. state: 'WAIT_FINANCE_AUDIT',
  75. checkWarehouseNo: ''
  76. },
  77. disabled: false, // 查询、重置按钮是否可操作
  78. tabPaneData: [
  79. { name: '未完结', type: 'WAIT_FINANCE_AUDIT' },
  80. { name: '已完结', type: 'FINISH' }
  81. ],
  82. // 加载数据方法 必须为 Promise 对象
  83. loadData: parameter => {
  84. this.disabled = true
  85. this.spinning = true
  86. return checkWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  87. const data = res.data
  88. const no = (data.pageNo - 1) * data.pageSize
  89. for (var i = 0; i < data.list.length; i++) {
  90. data.list[i].no = no + i + 1
  91. }
  92. this.disabled = false
  93. this.spinning = false
  94. return data
  95. })
  96. }
  97. }
  98. },
  99. computed: {
  100. columns () {
  101. let arr = []
  102. if (this.queryParam.state == 'WAIT_FINANCE_AUDIT') { // 未完结
  103. arr = [
  104. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  105. { title: '盘点单号', dataIndex: 'checkWarehouseNo', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '15%', align: 'center' },
  106. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '监盘状态', dataIndex: 'checkSuperviseStateDictValue', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '盘点人', dataIndex: 'checkPersonName', align: 'center', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  109. { title: '盘点时间', dataIndex: 'checkTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '监盘人', dataIndex: 'checkSupervisePersonName', align: 'center', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
  111. { title: '监盘时间', dataIndex: 'checkSuperviseTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  113. ]
  114. } else if (this.queryParam.state == 'FINISH') { // 已完结
  115. arr = [
  116. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  117. { title: '盘点单号', dataIndex: 'checkWarehouseNo', scopedSlots: { customRender: 'checkWarehouseNo' }, width: '14%', align: 'center' },
  118. { title: '盘点状态', dataIndex: 'checkStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '监盘状态', dataIndex: 'checkSuperviseStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '盘点人', dataIndex: 'checkPersonName', align: 'center', width: '16%', customRender: function (text) { return text || '--' }, ellipsis: true },
  121. { title: '盘点时间', dataIndex: 'checkTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '监盘人', dataIndex: 'checkSupervisePersonName', align: 'center', width: '16%', customRender: function (text) { return text || '--' }, ellipsis: true },
  123. { title: '监盘时间', dataIndex: 'checkSuperviseTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  124. { title: '财务确认时间', dataIndex: 'financeAuditTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  125. ]
  126. }
  127. return arr
  128. }
  129. },
  130. methods: {
  131. // 选择类型
  132. handleTabChange (key) {
  133. this.queryParam.state = key
  134. this.$refs.table.refresh(true)
  135. },
  136. // 详情
  137. handleDetail (row) {
  138. if (this.$hasPermissions('B_inventoryConfirmationDetail')) {
  139. this.$router.push({ path: `/financialManagement/inventoryConfirmation/detail/${row.checkWarehouseSn}` })
  140. }
  141. },
  142. // 盘点确认
  143. handleConfirm (row) {
  144. const _this = this
  145. this.$confirm({
  146. title: '提示',
  147. content: '确认盘点结果正确无误吗?',
  148. centered: true,
  149. closable: true,
  150. onOk () {
  151. _this.spinning = true
  152. checkWarehouseFinanceAudit({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
  153. if (res.status == 200) {
  154. _this.$message.success(res.message)
  155. _this.$refs.table.refresh(true)
  156. _this.spinning = false
  157. } else {
  158. _this.spinning = false
  159. }
  160. })
  161. }
  162. })
  163. },
  164. // 重新盘点
  165. handleCheck (row) {
  166. const _this = this
  167. this.$confirm({
  168. title: '提示',
  169. content: '确认要重新盘点吗?',
  170. centered: true,
  171. closable: true,
  172. onOk () {
  173. _this.spinning = true
  174. checkWarehouseReCheck({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
  175. if (res.status == 200) {
  176. _this.$message.success(res.message)
  177. _this.$refs.table.refresh(true)
  178. _this.spinning = false
  179. } else {
  180. _this.spinning = false
  181. }
  182. })
  183. }
  184. })
  185. },
  186. resetSearchForm () {
  187. this.queryParam.checkWarehouseNo = ''
  188. this.$refs.table.refresh(true)
  189. },
  190. pageInit () {
  191. const _this = this
  192. this.$nextTick(() => { // 页面渲染完成后的回调
  193. _this.setTableH()
  194. })
  195. },
  196. setTableH () {
  197. this.tableHeight = window.innerHeight - 295
  198. }
  199. },
  200. mounted () {
  201. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  202. this.pageInit()
  203. this.$refs.table.refresh(true)
  204. }
  205. },
  206. activated () {
  207. // 如果是新页签打开,则重置当前页面
  208. if (this.$store.state.app.isNewTab) {
  209. this.pageInit()
  210. this.$refs.table.refresh(true)
  211. }
  212. // 仅刷新列表,不重置页面
  213. if (this.$store.state.app.updateList) {
  214. this.pageInit()
  215. this.$refs.table.refresh()
  216. }
  217. },
  218. beforeRouteEnter (to, from, next) {
  219. next(vm => {})
  220. }
  221. }
  222. </script>
  223. <style lang="less">
  224. .inventoryConfirmationList-wrap{
  225. .active{
  226. color: #ed1c24;
  227. cursor: pointer;
  228. }
  229. .common{
  230. color: rgba(0, 0, 0, 0.65);
  231. }
  232. }
  233. </style>