list.vue 13 KB

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