list.vue 13 KB

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