list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocateBillList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <rangeDate ref="rangeDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="调往对象">
  14. <a-input id="allocateBillList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入调往对象"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="调拨类型">
  19. <a-select id="allocateBillList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择调拨类型" allowClear >
  20. <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
  21. </a-select>
  22. </a-form-item>
  23. </a-col>
  24. <template v-if="advanced">
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="业务状态">
  27. <v-select
  28. v-model="queryParam.state"
  29. ref="state"
  30. id="allocateBillList-state"
  31. code="ALLOCATE_STATUS"
  32. placeholder="请选择业务状态"
  33. allowClear
  34. ></v-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6" :sm="24">
  38. <a-form-item label="调拨单号">
  39. <a-input id="allocateBillList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  40. </a-form-item>
  41. </a-col>
  42. </template>
  43. <a-col :md="6" :sm="24">
  44. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="allocateBillList-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocateBillList-reset">重置</a-button>
  46. <!-- <a-button
  47. style="margin: 0 0 18px 5px"
  48. type="primary"
  49. class="button-warning"
  50. @click="handleExport"
  51. :disabled="disabled"
  52. :loading="exportLoading"
  53. id="allocateBillList-export">导出</a-button> -->
  54. <a @click="advanced=!advanced" style="margin-left: 8px">
  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 id="allocateBillList-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable"
  69. ref="table"
  70. size="default"
  71. :rowKey="(record) => record.id"
  72. :columns="columns"
  73. :data="loadData"
  74. :scroll="{ x: 1940, y: tableHeight }"
  75. bordered>
  76. <!-- 单号 -->
  77. <template slot="allocateNo" slot-scope="text, record">
  78. <span style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.allocateNo }}</span>
  79. </template>
  80. <!-- 财务状态 -->
  81. <template slot="settleState" slot-scope="text, record">
  82. <a-badge :color="text=='FINISH'?'#87d068':'gold'" :text="record.settleStateDictValue" />
  83. </template>
  84. <!-- 操作 -->
  85. <template slot="action" slot-scope="text, record">
  86. <a-button
  87. size="small"
  88. type="link"
  89. v-if="record.state == 'WAIT_AUDIT'"
  90. class="button-warning"
  91. @click="handleExamine(record)"
  92. id="allocateBillList-examine-btn">审核</a-button>
  93. <a-button
  94. size="small"
  95. type="link"
  96. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')"
  97. class="button-info"
  98. @click="handleEdit(record)"
  99. id="allocateBillList-edit-btn">编辑</a-button>
  100. <a-button
  101. size="small"
  102. type="link"
  103. v-if="(record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')"
  104. class="button-error"
  105. @click="handleDel(record)"
  106. id="allocateBillList-del-btn">删除</a-button>
  107. <span v-if="(record.state != 'WAIT_SUBMIT') && (record.state != 'WAIT_AUDIT') && (record.state != 'AUDIT_REJECT')">--</span>
  108. </template>
  109. </s-table>
  110. <!-- 新增 -->
  111. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  112. </a-card>
  113. </template>
  114. <script>
  115. import moment from 'moment'
  116. import { STable, VSelect } from '@/components'
  117. import basicInfoModal from './basicInfoModal.vue'
  118. import rangeDate from '@/views/common/rangeDate.vue'
  119. import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
  120. import { allocateTypeAllList } from '@/api/allocateType'
  121. export default {
  122. components: { STable, VSelect, basicInfoModal, rangeDate },
  123. data () {
  124. return {
  125. advanced: false, // 高级搜索 展开/关闭
  126. tableHeight: 0,
  127. queryParam: { // 查询条件
  128. beginDate: '',
  129. endDate: '',
  130. targetName: '', // 调往对象
  131. allocateTypeSn: undefined, // 调拨类型
  132. state: undefined, // 业务状态
  133. allocateNo: '' // 调拨单号
  134. },
  135. disabled: false, // 查询、重置按钮是否可操作
  136. exportLoading: false,
  137. columns: [
  138. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  139. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  140. { title: '调拨单号', scopedSlots: { customRender: 'allocateNo' }, align: 'center' },
  141. { title: '调往对象', dataIndex: 'targetName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  142. { title: '客户类型', dataIndex: 'dealerLevelDictValue', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '总数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  146. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '调拨类型', dataIndex: 'allocateTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '业务状态', dataIndex: 'stateDictValue', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '打印状态', dataIndex: 'printStateDictValue', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '打印次数', dataIndex: 'printCount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '操作', scopedSlots: { customRender: 'action' }, width: 180, align: 'center', fixed: 'right' }
  152. ],
  153. // 加载数据方法 必须为 Promise 对象
  154. loadData: parameter => {
  155. this.disabled = true
  156. if (this.tableHeight == 0) {
  157. this.tableHeight = window.innerHeight - 380
  158. }
  159. return allocateBillList(Object.assign(parameter, this.queryParam)).then(res => {
  160. const data = res.data
  161. const no = (data.pageNo - 1) * data.pageSize
  162. for (var i = 0; i < data.list.length; i++) {
  163. data.list[i].no = no + i + 1
  164. }
  165. this.disabled = false
  166. return data
  167. })
  168. },
  169. allocateTypeList: [], // 调拨类型
  170. openModal: false // 新增编辑 弹框
  171. }
  172. },
  173. methods: {
  174. // 创建时间 change
  175. dateChange (date) {
  176. this.queryParam.beginDate = date[0]
  177. this.queryParam.endDate = date[1]
  178. },
  179. // 重置
  180. resetSearchForm () {
  181. this.$refs.rangeDate.resetDate()
  182. this.queryParam.beginDate = ''
  183. this.queryParam.endDate = ''
  184. this.queryParam.targetName = ''
  185. this.queryParam.allocateTypeSn = undefined
  186. this.queryParam.state = undefined
  187. this.queryParam.allocateNo = ''
  188. this.$refs.table.refresh(true)
  189. },
  190. // 基本信息 保存
  191. handleOk (data) {
  192. this.$router.push({ path: `/allocationManagement/transferOut/add/${data.allocateSn}/${data.targetName}` })
  193. },
  194. // 删除
  195. handleDel (row) {
  196. const _this = this
  197. this.$confirm({
  198. title: '提示',
  199. content: '删除后不可恢复,确定要进行删除吗?',
  200. centered: true,
  201. onOk () {
  202. allocateBillDel({ sn: row.allocateSn }).then(res => {
  203. if (res.status == 200) {
  204. _this.$message.success(res.message)
  205. _this.$refs.table.refresh()
  206. }
  207. })
  208. }
  209. })
  210. },
  211. // 审核
  212. handleExamine (row) {
  213. const _this = this
  214. this.$confirm({
  215. title: '提示',
  216. content: '确认要审核通过吗?',
  217. centered: true,
  218. closable: true,
  219. okText: '审核通过',
  220. cancelText: '审核不通过',
  221. onOk () {
  222. _this.auditOrder(row.allocateSn, 'WAIT_OUT_WAREHOUSE')
  223. },
  224. onCancel (e) {
  225. if (!e.triggerCancel) {
  226. _this.auditOrder(row.allocateSn, 'AUDIT_REJECT')
  227. }
  228. _this.$destroyAll()
  229. }
  230. })
  231. },
  232. // 审核
  233. auditOrder (sn, state) {
  234. const _this = this
  235. allocateBillAudit({ sn: sn, state: state }).then(res => {
  236. if (res.status == 200) {
  237. _this.$message.success(res.message)
  238. _this.$refs.table.refresh()
  239. }
  240. })
  241. },
  242. // 详情
  243. handleDetail (row) {
  244. this.$router.push({ path: `/allocationManagement/transferOut/detail/${row.allocateSn}` })
  245. },
  246. // 编辑
  247. handleEdit (row) {
  248. this.$router.push({ path: `/allocationManagement/transferOut/edit/${row.allocateSn}/${row.targetName}/${row.dealerLevel}` })
  249. },
  250. // 导出
  251. handleExport () {
  252. const params = this.queryParam
  253. this.exportLoading = true
  254. allocateBillExport(params).then(res => {
  255. this.exportLoading = false
  256. this.download(res)
  257. })
  258. },
  259. download (data) {
  260. if (!data) { return }
  261. const url = window.URL.createObjectURL(new Blob([data]))
  262. const link = document.createElement('a')
  263. link.style.display = 'none'
  264. link.href = url
  265. const a = moment().format('YYYYMMDDHHmmss')
  266. const fname = '调拨列表' + a
  267. link.setAttribute('download', fname + '.xlsx')
  268. document.body.appendChild(link)
  269. link.click()
  270. },
  271. // 调拨类型
  272. getAllocateTypeAllList () {
  273. allocateTypeAllList().then(res => {
  274. if (res.status == 200) {
  275. this.allocateTypeList = res.data
  276. } else {
  277. this.allocateTypeList = []
  278. }
  279. })
  280. }
  281. },
  282. beforeRouteEnter (to, from, next) {
  283. next(vm => {
  284. vm.openModal = false
  285. vm.getAllocateTypeAllList()
  286. })
  287. }
  288. }
  289. </script>