list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocateBillList-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. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="调往对象">
  15. <a-input id="allocateBillList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入调往对象"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="调拨类型">
  20. <AllocateType id="allocateBillList-allocateTypeSn" v-model="queryParam.allocateTypeSn"></AllocateType>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="业务状态">
  26. <v-select
  27. v-model="queryParam.state"
  28. ref="state"
  29. id="allocateBillList-state"
  30. code="ALLOCATE_STATUS"
  31. placeholder="请选择业务状态"
  32. allowClear
  33. ></v-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="调拨单号">
  38. <a-input id="allocateBillList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  39. </a-form-item>
  40. </a-col>
  41. </template>
  42. <a-col :md="6" :sm="24">
  43. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="allocateBillList-refresh">查询</a-button>
  44. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocateBillList-reset">重置</a-button>
  45. <a-button
  46. style="margin-left: 5px"
  47. type="primary"
  48. class="button-warning"
  49. v-if="$hasPermissions('B_transferOut_export')"
  50. @click="handleExport"
  51. :disabled="disabled"
  52. :loading="exportLoading"
  53. id="allocateBillList-export">导出</a-button>
  54. <a @click="advanced=!advanced" style="margin-left: 5px">
  55. {{ advanced ? '收起' : '展开' }}
  56. <a-icon :type="advanced ? 'up' : 'down'"/>
  57. </a>
  58. </a-col>
  59. </a-row>
  60. </a-form>
  61. </div>
  62. <!-- 操作按钮 -->
  63. <div class="table-operator">
  64. <a-button v-if="$hasPermissions('B_transferOut_add')" id="allocateBillList-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable fixPagination"
  69. ref="table"
  70. :style="{ height: tableHeight+84.5+'px' }"
  71. size="small"
  72. :rowKey="(record) => record.id"
  73. :columns="columns"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. :scroll="{ y: tableHeight }"
  77. bordered>
  78. <!-- 单号 -->
  79. <template slot="allocateNo" slot-scope="text, record">
  80. <span :class="$hasPermissions('M_transferOut_detail')?'active':'common'" @click="handleDetail(record)">{{ record.allocateNo }}</span>
  81. </template>
  82. <!-- 操作 -->
  83. <template slot="action" slot-scope="text, record">
  84. <a-button
  85. size="small"
  86. type="link"
  87. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_transferOut_audit')"
  88. class="button-warning"
  89. @click="handleExamine(record)"
  90. id="allocateBillList-examine-btn">审核</a-button>
  91. <a-button
  92. size="small"
  93. type="link"
  94. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')) && $hasPermissions('M_transferOut_edit')"
  95. class="button-info"
  96. @click="handleEdit(record)"
  97. id="allocateBillList-edit-btn">编辑</a-button>
  98. <a-button
  99. size="small"
  100. type="link"
  101. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')) && $hasPermissions('B_transferOut_del')"
  102. class="button-error"
  103. @click="handleDel(record)"
  104. id="allocateBillList-del-btn">删除</a-button>
  105. <span v-if="((record.state != 'WAIT_SUBMIT') && (record.state != 'WAIT_AUDIT') && (record.state != 'AUDIT_REJECT'))||(!$hasPermissions('B_transferOut_audit') && !$hasPermissions('M_transferOut_edit') && !$hasPermissions('B_transferOut_del'))">--</span>
  106. </template>
  107. </s-table>
  108. </a-spin>
  109. <!-- 新增 -->
  110. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  111. <!-- 审核 -->
  112. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  113. </a-card>
  114. </template>
  115. <script>
  116. import moment from 'moment'
  117. import getDate from '@/libs/getDate.js'
  118. import { STable, VSelect } from '@/components'
  119. import basicInfoModal from './basicInfoModal.vue'
  120. import rangeDate from '@/views/common/rangeDate.vue'
  121. import auditModal from '@/views/common/auditModal.vue'
  122. import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
  123. import AllocateType from '@/views/common/allocateType.js'
  124. import { hdExportExcel } from '@/libs/exportExcel'
  125. export default {
  126. components: { STable, VSelect, basicInfoModal, rangeDate, auditModal, AllocateType },
  127. data () {
  128. return {
  129. spinning: false,
  130. advanced: true, // 高级搜索 展开/关闭
  131. tableHeight: 0,
  132. time: [
  133. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  134. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  135. ],
  136. queryParam: { // 查询条件
  137. beginDate: getDate.getThreeMonthDays().starttime,
  138. endDate: getDate.getCurrMonthDays().endtime,
  139. targetName: '', // 调往对象
  140. allocateTypeSn: undefined, // 调拨类型
  141. state: undefined, // 业务状态
  142. allocateNo: '' // 调拨单号
  143. },
  144. disabled: false, // 查询、重置按钮是否可操作
  145. exportLoading: false,
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. this.spinning = true
  150. return allocateBillList(Object.assign(parameter, this.queryParam)).then(res => {
  151. const data = res.data
  152. const no = (data.pageNo - 1) * data.pageSize
  153. for (var i = 0; i < data.list.length; i++) {
  154. data.list[i].no = no + i + 1
  155. }
  156. this.disabled = false
  157. this.spinning = false
  158. return data
  159. })
  160. },
  161. visibleAudit: false,
  162. auditInfo: null,
  163. spinningAudit: false,
  164. openModal: false // 新增编辑 弹框
  165. }
  166. },
  167. computed: {
  168. columns () {
  169. const arr = [
  170. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  171. { title: '创建时间', dataIndex: 'createDate', width: '8.5%', align: 'center', customRender: function (text) { return text || '--' } },
  172. { title: '调拨单号', scopedSlots: { customRender: 'allocateNo' }, align: 'center', width: '15%' },
  173. { title: '调往对象', dataIndex: 'targetName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  174. { title: '客户类型', dataIndex: 'dealerLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  175. { title: '总数量', dataIndex: 'totalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  176. { title: '总售价', dataIndex: 'totalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  177. { title: '审核时间', dataIndex: 'auditTime', width: '8.5%', align: 'center', customRender: function (text) { return text || '--' } },
  178. { title: '调拨类型', dataIndex: 'allocateTypeName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  179. { title: '业务状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  180. { title: '打印状态', dataIndex: 'printStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '打印次数', dataIndex: 'printCount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  182. { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
  183. ]
  184. if (this.$hasPermissions('B_isShowCost')) {
  185. arr.splice(6, 0, { title: '总成本', dataIndex: 'totalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  186. }
  187. return arr
  188. }
  189. },
  190. methods: {
  191. // 创建时间 change
  192. dateChange (date) {
  193. this.queryParam.beginDate = date[0]
  194. this.queryParam.endDate = date[1]
  195. },
  196. // 重置
  197. resetSearchForm () {
  198. this.$refs.rangeDate.resetDate(this.time)
  199. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  200. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  201. this.queryParam.targetName = ''
  202. this.queryParam.allocateTypeSn = undefined
  203. this.queryParam.state = undefined
  204. this.queryParam.allocateNo = ''
  205. this.$refs.table.refresh(true)
  206. },
  207. // 基本信息 保存
  208. handleOk (data) {
  209. this.$router.push({ path: `/allocationManagement/transferOut/add/${data.allocateSn}/${data.dealerLevel}` })
  210. },
  211. // 删除
  212. handleDel (row) {
  213. const _this = this
  214. this.$confirm({
  215. title: '提示',
  216. content: '删除后不可恢复,确定要进行删除吗?',
  217. centered: true,
  218. onOk () {
  219. _this.spinning = true
  220. allocateBillDel({ sn: row.allocateSn }).then(res => {
  221. if (res.status == 200) {
  222. _this.$message.success(res.message)
  223. _this.$refs.table.refresh()
  224. _this.spinning = false
  225. } else {
  226. _this.spinning = false
  227. }
  228. })
  229. }
  230. })
  231. },
  232. // 审核
  233. handleExamine (row) {
  234. this.auditInfo = row
  235. this.visibleAudit = true
  236. },
  237. // 审核
  238. auditOrder (state) {
  239. const _this = this
  240. _this.spinningAudit = true
  241. allocateBillAudit({ sn: this.auditInfo.allocateSn, state: state }).then(res => {
  242. if (res.status == 200) {
  243. _this.visibleAudit = false
  244. _this.$message.success(res.message)
  245. _this.$refs.table.refresh()
  246. _this.spinningAudit = false
  247. } else {
  248. _this.visibleAudit = false
  249. _this.spinningAudit = false
  250. }
  251. })
  252. },
  253. // 详情
  254. handleDetail (row) {
  255. if (this.$hasPermissions('M_transferOut_detail')) {
  256. this.$router.push({ path: `/allocationManagement/transferOut/detail/${row.allocateSn}` })
  257. }
  258. },
  259. // 编辑
  260. handleEdit (row) {
  261. this.$router.push({ path: `/allocationManagement/transferOut/edit/${row.allocateSn}/${row.dealerLevel}` })
  262. },
  263. // 导出
  264. handleExport () {
  265. const _this = this
  266. const params = this.queryParam
  267. this.exportLoading = true
  268. this.spinning = true
  269. hdExportExcel(allocateBillExport, params, '调拨列表', function () {
  270. _this.exportLoading = false
  271. _this.spinning = false
  272. })
  273. },
  274. pageInit () {
  275. const _this = this
  276. this.$nextTick(() => { // 页面渲染完成后的回调
  277. _this.setTableH()
  278. })
  279. this.openModal = false
  280. },
  281. setTableH () {
  282. const tableSearchH = this.$refs.tableSearch.offsetHeight
  283. this.tableHeight = window.innerHeight - tableSearchH - 235
  284. }
  285. },
  286. watch: {
  287. advanced (newValue, oldValue) {
  288. const _this = this
  289. setTimeout(() => {
  290. _this.setTableH()
  291. }, 400)
  292. }
  293. },
  294. mounted () {
  295. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  296. this.pageInit()
  297. this.resetSearchForm()
  298. }
  299. },
  300. activated () {
  301. // 如果是新页签打开,则重置当前页面
  302. if (this.$store.state.app.isNewTab) {
  303. this.pageInit()
  304. this.resetSearchForm()
  305. }
  306. // 仅刷新列表,不重置页面
  307. if (this.$store.state.app.updateList) {
  308. this.pageInit()
  309. this.$refs.table.refresh()
  310. }
  311. },
  312. beforeRouteEnter (to, from, next) {
  313. next(vm => {})
  314. }
  315. }
  316. </script>
  317. <style lang="less">
  318. .active{
  319. color: #ed1c24;
  320. cursor: pointer;
  321. }
  322. .common{
  323. color: rgba(0, 0, 0, 0.65);
  324. }
  325. </style>