list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <div class="salesDetail-wrap" :style="{paddingBottom:hideFooter?'0px':'45px'}">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesDetail-cont">
  5. <template slot="subTitle">
  6. <a href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. </template>
  8. </a-page-header>
  9. <a-card size="small" :bordered="false" class="pages-wrap">
  10. <!-- 查询 -->
  11. <div class="table-page-search-wrapper" ref="searchbox">
  12. <div style="display: flex;justify-content: space-between;align-items: center;">
  13. <div style="flex-grow: 1;width: 60%;">
  14. <a-form layout="inline" @keyup.enter.native="searchTable">
  15. <a-row :gutter="15" type="flex">
  16. <a-col flex="300px">
  17. <a-form-item label="促销名称/简称">
  18. <a-input v-model.trim="queryParam.promotionDescription" allowClear placeholder="请输入促销名称/简称"/>
  19. </a-form-item>
  20. </a-col>
  21. <a-col flex="300px">
  22. <a-form-item label="费用类型">
  23. <v-select
  24. v-model="queryParam.convertExpenseAccountType"
  25. code="CONVERT_EXPENSE_ACCOUNT_TYPE"
  26. placeholder="请选择费用类型"
  27. allowClear></v-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col flex="300px">
  31. <a-form-item label="客户名称">
  32. <dealerSubareaScopeList ref="dealerSubareaScopeList" @change="custChange" />
  33. </a-form-item>
  34. </a-col>
  35. <a-col flex="300px">
  36. <a-form-item label="销售单号">
  37. <a-input v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  38. </a-form-item>
  39. </a-col>
  40. <a-col flex="300px">
  41. <a-form-item label="规则简称">
  42. <a-input v-model.trim="queryParam.promotionRuleDescription" allowClear placeholder="请输入规则简称"/>
  43. </a-form-item>
  44. </a-col>
  45. <a-col flex="150px">
  46. <a-button type="primary" :disabled="disabled" @click="searchForm">查询</a-button>
  47. <a-button style="margin-left: 10px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  48. </a-col>
  49. </a-row>
  50. </a-form>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- 产品列表 -->
  55. <div style="padding:0 0 5px;">
  56. <span>
  57. 已选 <template v-if="rowSelectionInfo && rowSelectionInfo.selectedRowKeys.length>0">{{ rowSelectionInfo.selectedRowKeys.length }}</template><template v-else>0</template> 项
  58. </span>
  59. </div>
  60. <div>
  61. <s-table
  62. class="sTable fixPagination"
  63. ref="table"
  64. :style="{ height: pageHeight+67+'px' }"
  65. size="small"
  66. :rowKey="(record) => record.no"
  67. rowKeyName="no"
  68. :columns="columns"
  69. :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: curExpenseAccountType ? record.convertExpenseAccountType != curExpenseAccountType : false } }) }"
  70. @rowSelection="rowSelectionFun"
  71. :data="loadData"
  72. :scroll="{ y: pageHeight }"
  73. :defaultLoadData="false"
  74. bordered>
  75. <!-- 操作 -->
  76. <template slot="action" slot-scope="text, record">
  77. <div>
  78. <a-button
  79. size="small"
  80. type="link"
  81. class="button-warning"
  82. @click="handleSave(record)"
  83. >转费用报销单</a-button>
  84. </div>
  85. </template>
  86. </s-table>
  87. </div>
  88. </a-card>
  89. </a-spin>
  90. <div class="affix-cont" :style="{padding:hideFooter?0:'7px 0 4px'}">
  91. <a-button
  92. style="width: 100px;"
  93. type="primary"
  94. class="button-info"
  95. @click="handleView()"
  96. >
  97. 查看
  98. </a-button>
  99. <a-button
  100. type="primary"
  101. :disabled="spinning"
  102. style="width: 100px;margin: 0 20px;"
  103. @click="handleSave()"
  104. >
  105. 提交
  106. </a-button>
  107. </div>
  108. <!-- 新增费用单 -->
  109. <baseDataModal ref="expenseModal" @expenseSaveOk="expenseSaveOk" :show="openBaseModal" @close="openBaseModal=false"></baseDataModal>
  110. <!-- 查看已选费用单 -->
  111. <viewSelectModal ref="viewModal" :openModal="showViewModal" @close="showViewModal=false"></viewSelectModal>
  112. </div>
  113. </template>
  114. <script>
  115. import { commonMixin } from '@/utils/mixin'
  116. import moment from 'moment'
  117. import { STable, VSelect } from '@/components'
  118. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  119. import baseDataModal from '@/views/expenseManagement/expenseReimbursement/baseDataModal.vue'
  120. import viewSelectModal from './viewSelectModal.vue'
  121. import { salesConvertExpenseList, expenseAccountSave, queryBatchCreateBySalesBillSn } from '@/api/salesNew'
  122. export default {
  123. name: 'WaitCostOrder',
  124. mixins: [commonMixin],
  125. components: { STable, VSelect, dealerSubareaScopeList, baseDataModal, viewSelectModal },
  126. data () {
  127. return {
  128. spinning: false,
  129. disabled: false,
  130. hideFooter: false,
  131. openBaseModal: false, // 费用弹框
  132. fromRouter: '',
  133. authCode: '',
  134. queryParam: {
  135. promotionDescription: '',
  136. convertExpenseAccountType: '',
  137. salesBillNo: '',
  138. promotionRuleDescription: '',
  139. buyerName: ''
  140. },
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. this.disabled = true
  144. this.spinning = true
  145. delete parameter.tableId
  146. delete parameter.index
  147. this.getPageHeight()
  148. return salesConvertExpenseList(Object.assign(parameter, this.queryParam)).then(res => {
  149. let data
  150. if (res.status == 200) {
  151. data = res.data
  152. const no = (data.pageNo - 1) * data.pageSize
  153. data.list.forEach((con, i) => {
  154. con.no = no + i + 1
  155. })
  156. this.disabled = false
  157. }
  158. this.spinning = false
  159. return data
  160. })
  161. },
  162. rowSelectionInfo: null,
  163. curExpenseAccountType: '',
  164. pageHeight: 300,
  165. showViewModal: false,
  166. isSearch: false
  167. }
  168. },
  169. computed: {
  170. hasSelect () {
  171. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length
  172. },
  173. columns () {
  174. const _this = this
  175. const arr = [
  176. { title: '序号', dataIndex: 'no', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '销售单号', dataIndex: 'salesBillNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  178. { title: '客户名称', dataIndex: 'buyerName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  179. { title: '费用类型', dataIndex: 'convertExpenseAccountTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  180. { title: '待转金额', dataIndex: 'expense', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  181. { title: '促销名称', dataIndex: 'promotionTitle', width: '17%', align: 'left', customRender: function (text) { return text || '--' } },
  182. { title: '促销简称', dataIndex: 'promotionDescription', width: '17%', align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  183. { title: '规则简称', dataIndex: 'promotionRuleDescription', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  184. { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  186. ]
  187. return arr
  188. }
  189. },
  190. methods: {
  191. // 返回
  192. handleBack () {
  193. this.$router.push({ name: 'salesQueryNewList' })
  194. },
  195. getPageHeight () {
  196. this.pageHeight = window.innerHeight - 290 - (this.$refs.searchbox ? this.$refs.searchbox.clientHeight : 0)
  197. },
  198. // 表格选中项
  199. rowSelectionFun (obj) {
  200. console.log(obj)
  201. this.rowSelectionInfo = obj || null
  202. if (obj.selectedRows) {
  203. this.curExpenseAccountType = obj.selectedRows && obj.selectedRows[0] && obj.selectedRows[0]['convertExpenseAccountType'] || ''
  204. if (obj.selectedRows.length <= 1) {
  205. if (!this.isSearch) {
  206. this.$refs.table.refresh()
  207. }
  208. this.isSearch = false
  209. } else {
  210. // 全选
  211. const ret = obj.selectedRows.filter(item => item.convertExpenseAccountType == this.curExpenseAccountType)
  212. if (ret.length != obj.selectedRows.length) {
  213. this.$message.warning('所选数据费用类型不一致!')
  214. this.$refs.table.clearSelected()
  215. }
  216. }
  217. }
  218. },
  219. custChange (val) {
  220. this.queryParam.buyerName = val.name || ''
  221. },
  222. // 提交
  223. handleSave (row) {
  224. const _this = this
  225. const salesPromoSnList = []
  226. // 单个转
  227. if (row) {
  228. salesPromoSnList.push(row.salesPromoSn)
  229. } else {
  230. const slen = _this.rowSelectionInfo.selectedRowKeys.length
  231. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
  232. _this.$message.warning('请在列表勾选后再进行批量操作!')
  233. return
  234. }
  235. // 批量转
  236. this.rowSelectionInfo.selectedRows.map(item => {
  237. salesPromoSnList.push(item.salesPromoSn)
  238. })
  239. }
  240. this.handleExpense(salesPromoSnList)
  241. },
  242. // 转费用单
  243. async handleExpense (snList) {
  244. const _this = this
  245. const hasExpense = await queryBatchCreateBySalesBillSn({ salesPromoSnList: snList }).then(res => res.data || [])
  246. let result = null
  247. for (const key in hasExpense) {
  248. result = hasExpense[key]
  249. }
  250. _this.expenseSave(result)
  251. },
  252. // 转费用单
  253. expenseSave (data) {
  254. console.log(data)
  255. if (data) {
  256. this.openBaseModal = true
  257. this.$refs.expenseModal.setDetail(data, 'sales')
  258. }
  259. },
  260. expenseSaveOk (params) {
  261. expenseAccountSave(params).then(res => {
  262. if (res.status == 200) {
  263. this.$message.info(res.message)
  264. this.openBaseModal = false
  265. this.searchForm()
  266. this.$router.push({ name: 'expenseReimbursementEdit', params: { sn: res.data.expenseAccountSn } })
  267. }
  268. })
  269. },
  270. // 查看
  271. handleView () {
  272. if (!this.hasSelect) {
  273. this.$message.warning('请先勾选!')
  274. return
  275. }
  276. this.showViewModal = true
  277. this.$refs.viewModal.setData(this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
  278. },
  279. // 重置
  280. resetSearchForm () {
  281. this.isSearch = true
  282. this.queryParam.buyerName = undefined
  283. this.queryParam.convertExpenseAccountType = undefined
  284. this.queryParam.salesBillNo = ''
  285. this.queryParam.promotionDescription = ''
  286. this.queryParam.promotionRuleDescription = ''
  287. this.$refs.dealerSubareaScopeList.resetForm()
  288. this.$refs.table.refresh(true)
  289. this.$refs.table.clearSelected()
  290. },
  291. searchForm () {
  292. this.isSearch = true
  293. this.$refs.table.refresh(true)
  294. this.$refs.table.clearSelected()
  295. }
  296. },
  297. activated () {
  298. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  299. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  300. this.resetSearchForm()
  301. }
  302. },
  303. beforeRouteEnter (to, from, next) {
  304. next(vm => {
  305. vm.fromRouter = from
  306. vm.authCode = to.meta.permission
  307. })
  308. }
  309. }
  310. </script>
  311. <style lang="less">
  312. .salesDetail-wrap{
  313. position: relative;
  314. height: 100%;
  315. padding-bottom: 45px;
  316. box-sizing: border-box;
  317. >.ant-spin-nested-loading{
  318. overflow-y: auto;
  319. height: 100%;
  320. }
  321. .salesDetail-cont{
  322. margin-bottom: 6px;
  323. }
  324. .active-title{
  325. display: flex;
  326. align-items: center;
  327. justify-content: space-between;
  328. padding: 10px;
  329. background: #f3f8fa;
  330. }
  331. .flexBox{
  332. display: flex;
  333. justify-content: space-between;
  334. align-items: center;
  335. }
  336. .footer-cont{
  337. margin-top: 5px;
  338. text-align: center;
  339. }
  340. .redStyle{
  341. font-weight: bold;
  342. color: red;
  343. }
  344. }
  345. </style>