index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title+'-列表', essential: true }]">
  3. <template slot-scope="{activeKey, data}">
  4. <template-page ref="pageRef" v-if="tabIndexShow && activeKey == 'list'" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="120" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  5. :operation="operation()" :exportList="tabIndex==1?exportList1:exportList2">
  6. <div slot="moreSearch" style="margin-bottom: 10px;">
  7. <el-radio-group v-model="tabIndex" size="mini" @change="changeType">
  8. <el-radio-button label="1">汇总</el-radio-button>
  9. <el-radio-button label="2">明细</el-radio-button>
  10. </el-radio-group>
  11. </div>
  12. <div slot="moreSearch" v-if="tabIndex == 2">
  13. <el-radio-group v-model="status" size="mini" @change="changeType">
  14. <el-radio-button label="">全部</el-radio-button>
  15. <el-radio-button label="WAIT">待结算</el-radio-button>
  16. <el-radio-button label="OVER">已完成</el-radio-button>
  17. </el-radio-group>
  18. <br><br>
  19. </div>
  20. </template-page>
  21. <div v-if="~['detail'].indexOf(activeKey)">
  22. <el-card class="box-card">
  23. <div slot="header" class="clearfix">
  24. <span>基础信息</span>
  25. </div>
  26. <table border="1" style="border-color: #fff;" width="100%" align="center" cellspacing="0" cellpadding="10">
  27. <tr>
  28. <td class="bold" align="center">所属商户</td>
  29. <td>{{formData.companyWechatName}}</td>
  30. <td class="bold" align="center">关联工单号</td>
  31. <td>{{formData.workerOrderId}}</td>
  32. <td class="bold" align="center">结算单号</td>
  33. <td>{{formData.settlementOrderId}}</td>
  34. <td class="bold" align="center">工单品牌</td>
  35. <td>{{formData.brand}}</td>
  36. </tr>
  37. <tr>
  38. <td class="bold" align="center">客户姓名</td>
  39. <td>{{formData.userName}}</td>
  40. <td class="bold" align="center">客户电话</td>
  41. <td>{{formData.userMobile}}</td>
  42. <td class="bold" align="center">师傅姓名</td>
  43. <td>{{formData.workerName}}</td>
  44. <td class="bold" align="center">师傅身份证号</td>
  45. <td>{{formData.identity}}</td>
  46. </tr>
  47. <tr>
  48. <td class="bold" align="center">师傅联系电话</td>
  49. <td>{{formData.workerMobile}}</td>
  50. <td class="bold" align="center">订单金额</td>
  51. <td>{{formData.totalAmount}}</td>
  52. <td class="bold" align="center">销售类型</td>
  53. <td>{{formData.settlementType == 'OWN'?'自由':formData.settlementType == 'OUT'?'外购':''}}</td>
  54. <td class="bold" align="center">创建人</td>
  55. <td>{{formData.createBy}}</td>
  56. </tr>
  57. <tr>
  58. <td class="bold" align="center">创建时间</td>
  59. <td>{{formData.createTime}}</td>
  60. <td class="bold" align="center">支付状态</td>
  61. <td>{{formData.payStatus == 'CANCEL'?'取消':formData.payStatus == 'PAID'?'已支付':formData.payStatus == 'WAIT'?'待支付':''}}</td>
  62. <td class="bold" align="center">操作人</td>
  63. <td>{{formData.updateBy}}</td>
  64. <td class="bold" align="center">操作时间</td>
  65. <td>{{formData.updateTime}}</td>
  66. </tr>
  67. </table>
  68. </el-card>
  69. <el-card class="box-card">
  70. <div slot="header" class="clearfix">
  71. <span>订单信息</span>
  72. </div>
  73. <table border="1" style="border-color: #fff;" width="100%" align="center" cellspacing="0" cellpadding="10">
  74. <thead>
  75. <tr>
  76. <th class="bold" align="center">名称</th>
  77. <th class="bold" align="center">收费类型</th>
  78. <th class="bold" align="center">工单类型</th>
  79. <th class="bold" align="center">数量</th>
  80. <th class="bold" align="center">单价</th>
  81. <th class="bold" align="center">订单金额</th>
  82. <th class="bold" align="center">销售类型</th>
  83. <th class="bold" align="center">师傅分账金额</th>
  84. <th class="bold" align="center">商户分账金额</th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. <tr v-for="(item,index) in formData.settlementOrderItemList" :key="index">
  89. <td align="center">{{item.goodsName}}</td>
  90. <td align="center">{{item.chargeType == 'ACC' ? '配件物料': item.chargeType == 'SERV' ? '服务收费':'辅材物料'}}</td>
  91. <td align="center">{{ formData.saleType | saleTypeFilter }}</td>
  92. <td align="center">{{item.num}}</td>
  93. <td align="center">{{item.goodsAmount}}</td>
  94. <td align="center">{{item.totalAmount}}</td>
  95. <td align="center">{{item.settlementType == 'OWN'?'自有':item.settlementType == 'OUT'?'外购':''}}</td>
  96. <td align="center">{{item.workerAmount}}</td>
  97. <td align="center">{{item.websitAmount}}</td>
  98. </tr>
  99. <tr>
  100. <td align="center">总计</td><td></td><td></td><td></td><td></td>
  101. <td align="center">{{totalAmount}}</td><td></td>
  102. <td align="center">{{workerAmount}}</td>
  103. <td align="center">{{websitAmount}}</td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </el-card>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button size="mini" @click="formDialog = false; formData = {};data.removeTab()">取 消</el-button>
  110. <el-button size="mini" v-if="formData.status == 'WAIT'" type="primary"
  111. @click="settleAccounts(formData.settlementOrderId,data.removeTab,2)">确认结算
  112. </el-button>
  113. <!-- <el-button size="mini" v-if="formData.status == 'WAIT_ING'" type="primary" @click="withdraw(formData.settlementOrderId,data.removeTab)">
  114. 确认提现
  115. </el-button> -->
  116. </div>
  117. </div>
  118. </template>
  119. </zj-tab-page>
  120. </template>
  121. <script>
  122. import TemplatePage from '@/components/template/template-page-1.vue'
  123. import import_mixin from '@/components/template/import_mixin.js'
  124. import operation_mixin from '@/components/template/operation_mixin.js'
  125. import ImageUpload from '@/components/file-upload'
  126. import { downloadFiles } from '@/utils/util'
  127. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  128. import { listPageV1,listPageV2,pageExport1,pageExport2, getDetail, refund, settleAccounts } from "@/api/auxiliaryFittings/settleAccountOfflinePay";
  129. export default {
  130. components: { TemplatePage, ImageUpload },
  131. mixins: [import_mixin,operation_mixin],
  132. filters: {
  133. saleTypeFilter(val) {
  134. const MAP = {
  135. 1: '零售',
  136. 2: '工程',
  137. 3: '延保',
  138. 4: '工程维保',
  139. }
  140. return MAP[val];
  141. }
  142. },
  143. data() {
  144. return {
  145. // 表格属性
  146. tableAttributes: {
  147. // 启用勾选列
  148. selectColumn: true
  149. },
  150. // 表格事件
  151. tableEvents: {
  152. 'selection-change': this.selectionChange
  153. },
  154. // 勾选选中行
  155. recordSelected: [],
  156. formDialogType: 0,
  157. formDialogTitles: ["新增","编辑", "详情"],
  158. formDialog: false,
  159. formData: {},
  160. tabIndex: this?.$route?.params?.pageType || 1,
  161. status: this?.$route?.params?.pageCode || '',
  162. totalAmount: 0,
  163. workerAmount: 0,
  164. websitAmount: 0,
  165. workerId: '',
  166. websitId: '',
  167. tabIndexShow: true,
  168. formType: 'add',
  169. formVisible: false,
  170. }
  171. },
  172. watch: {
  173. tabIndex() {
  174. this.tabIndexShow = false
  175. this.$nextTick(() => {
  176. if(this.tabIndex == 1){
  177. this.status = ''
  178. this.workerId = ''
  179. this.websitId = ''
  180. }
  181. this.tabIndexShow = true
  182. })
  183. }
  184. },
  185. computed: {
  186. // 事件组合
  187. optionsEvensGroup() {
  188. return [
  189. [
  190. [
  191. this.optionsEvensAuth("bulkSettlement", {
  192. isRole: this.tabIndex== 2,
  193. click: () => {
  194. this.batchSettleAccounts()
  195. }
  196. })
  197. ],
  198. ]
  199. ]
  200. },
  201. // 更多参数
  202. moreParameters() {
  203. return []
  204. }
  205. },
  206. methods: {
  207. // 切换状态
  208. changeType(val) {
  209. this.workerId = ''
  210. this.websitId = ''
  211. this.$refs.pageRef.refreshList()
  212. },
  213. // 列表请求函数
  214. getList(p) {
  215. try {
  216. var pam = JSON.parse(JSON.stringify(p))
  217. pam.params.push({ "param": "a.pay_type", "compare": "=", "value": 'LINE' })
  218. if (this.status && this.tabIndex==2) {
  219. pam.params.push({ "param": "a.status", "compare": "=", "value": this.status })
  220. }
  221. if(this.workerId){
  222. pam.params.push({ "param": "a.websit_id", "compare": "=", "value": this.websitId },{ "param": "a.worker_id", "compare": "=", "value": this.workerId })
  223. }
  224. return this.tabIndex==1?listPageV1(pam):listPageV2(pam)
  225. } catch (error) {
  226. console.log(error)
  227. }
  228. },
  229. // 列表导出函数
  230. exportList1: pageExport1,
  231. exportList2: pageExport2,
  232. // 表格列解析渲染数据更改
  233. columnParsing(item, defaultData) {
  234. return defaultData
  235. },
  236. // 监听勾选变化
  237. selectionChange(data) {
  238. this.recordSelected = data
  239. },
  240. openForm(type, id) {
  241. this.$refs.tabPage.addTab({
  242. // 对应显示的模块
  243. activeKey: type,
  244. // 唯一标识
  245. key: type,
  246. // 页签名称
  247. label: ({ detail: "详情" })[type],
  248. // 打开时事件
  249. triggerEvent: () => {
  250. this.formCancel()
  251. this.$nextTick(()=>{
  252. this.formType = type
  253. this.formVisible = true
  254. if (type == 'detail') {
  255. this.formDialogType = 1
  256. this.totalAmount = 0
  257. this.workerAmount = 0
  258. this.websitAmount = 0
  259. getDetail({ id }).then(res => {
  260. Object.assign(this.formData, res.data)
  261. res.data.settlementOrderItemList.forEach(item=>{
  262. this.totalAmount += (item.totalAmount*100 + this.totalAmount*100)/100
  263. this.workerAmount = (item.workerAmount*100 + this.workerAmount*100)/100
  264. this.websitAmount += (item.websitAmount*100 + this.websitAmount*100)/100
  265. })
  266. })
  267. }
  268. })
  269. },
  270. // 关闭时事件
  271. closeEvent: () => {
  272. }
  273. })
  274. },
  275. formCancel() {
  276. this.formVisible = false
  277. this.$refs?.formRef?.resetFields()
  278. this.$data.formData = this.$options.data().formData
  279. },
  280. // 表格操作列
  281. operation() {
  282. return this.operationBtn({
  283. detail: {
  284. btnType: 'text',
  285. name: ({ row, index, column }) => {
  286. return this.tabIndex==1?'查看明细':'详情'
  287. },
  288. click: ({ row, index, column }) => {
  289. if(this.tabIndex==1){
  290. this.workerId = row.workerId
  291. this.websitId = row.websitId
  292. this.tabIndex = 2
  293. this.$refs.pageRef.refreshList()
  294. }else{
  295. this.openForm('detail',row.settlementOrderId)
  296. }
  297. }
  298. },
  299. refund: {
  300. btnType: 'text',
  301. prompt: '确认是否退款?',
  302. conditions: ({ row, index, column }) => {
  303. return row.totalAmount > 0 && row.refundStatus == 'NO' && this.tabIndex==2
  304. },
  305. click: ({ row, index, column }) => {
  306. refund({ id: row.settlementOrderId }).then(res => {
  307. if (res.code == 200) {
  308. this.$message({ type: 'success', message: '退款成功!' })
  309. this.$refs.pageRef.refreshList()
  310. } else {
  311. this.$message.error(res.msg);
  312. }
  313. })
  314. }
  315. },
  316. settlement: {
  317. btnType: 'text',
  318. conditions: ({ row, index, column }) => {
  319. return row.status == 'WAIT' || this.tabIndex==1
  320. },
  321. click: ({ row, index, column }) => {
  322. if(this.tabIndex==1){
  323. this.status = 'WAIT'
  324. this.workerId = row.workerId
  325. this.websitId = row.websitId
  326. this.tabIndex = 2
  327. this.$refs.pageRef.refreshList()
  328. }else{
  329. this.settleAccounts(row.settlementOrderId)
  330. }
  331. }
  332. }
  333. })
  334. },
  335. batchSettleAccounts(){
  336. if(this.recordSelected.length == 0){
  337. return this.$message.warning('请至少勾选一条数据!');
  338. }
  339. this.settleAccounts(this.recordSelected.map(item=>{return item.settlementOrderId}).join(','))
  340. },
  341. settleAccounts(id,cancel,type){
  342. this.$confirm(`请确认是否结算选中数据, 是否继续?`, '提示', {
  343. confirmButtonText: '确定',
  344. cancelButtonText: '取消',
  345. type: 'warning'
  346. }).then(() => {
  347. settleAccounts({
  348. id
  349. }).then(res => {
  350. if (res.code == 200) {
  351. this.$message({ type: 'success', message: `结算成功!` })
  352. if(type== 2){cancel('list')}
  353. this.$refs.pageRef.refreshList()
  354. this.formDialog = false
  355. } else {
  356. this.$message.error(res.msg);
  357. }
  358. })
  359. });
  360. }
  361. }
  362. }
  363. </script>
  364. <style lang="scss" scoped>
  365. .tab{
  366. padding: 20px 20px 0 20px;
  367. }
  368. .bold{
  369. width: 160px;
  370. font-weight: bold;
  371. background-color: #f0f0f0;
  372. }
  373. </style>