index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. </tr>
  85. </thead>
  86. <tbody>
  87. <tr v-for="(item,index) in formData.settlementOrderItemList" :key="index">
  88. <td align="center">{{item.goodsName}}</td>
  89. <td align="center">{{item.chargeType=='ACC'?(item.goodsType == 'M'?'辅材':'配件')+'物料':item.chargeType=='SERV'?'服务收费':''}}</td>
  90. <td align="center">{{item.num}}</td>
  91. <td align="center">{{item.goodsAmount}}</td>
  92. <td align="center">{{item.totalAmount}}</td>
  93. <td align="center">{{item.settlementType == 'OWN'?'自有':item.settlementType == 'OUT'?'外购':''}}</td>
  94. <td align="center">{{item.workerAmount}}</td>
  95. <td align="center">{{item.websitAmount}}</td>
  96. </tr>
  97. <tr>
  98. <td align="center">总计</td><td></td><td></td><td></td>
  99. <td align="center">{{totalAmount}}</td><td></td>
  100. <td align="center">{{workerAmount}}</td>
  101. <td align="center">{{websitAmount}}</td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. </el-card>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button size="mini" @click="formDialog = false; formData = {};data.removeTab()">取 消</el-button>
  108. <el-button size="mini" v-if="formData.status == 'WAIT'" type="primary"
  109. @click="settleAccounts(formData.settlementOrderId,data.removeTab,2)">确认结算
  110. </el-button>
  111. <!-- <el-button size="mini" v-if="formData.status == 'WAIT_ING'" type="primary" @click="withdraw(formData.settlementOrderId,data.removeTab)">
  112. 确认提现
  113. </el-button> -->
  114. </div>
  115. </div>
  116. </template>
  117. </zj-tab-page>
  118. </template>
  119. <script>
  120. import TemplatePage from '@/components/template/template-page-1.vue'
  121. import import_mixin from '@/components/template/import_mixin.js'
  122. import operation_mixin from '@/components/template/operation_mixin.js'
  123. import ImageUpload from '@/components/file-upload'
  124. import { downloadFiles } from '@/utils/util'
  125. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  126. import { listPageV1,listPageV2,pageExport1,pageExport2, getDetail, refund, settleAccounts } from "@/api/auxiliaryFittings/settleAccountOfflinePay";
  127. export default {
  128. components: { TemplatePage, ImageUpload },
  129. mixins: [import_mixin,operation_mixin],
  130. data() {
  131. return {
  132. // 表格属性
  133. tableAttributes: {
  134. // 启用勾选列
  135. selectColumn: true
  136. },
  137. // 表格事件
  138. tableEvents: {
  139. 'selection-change': this.selectionChange
  140. },
  141. // 勾选选中行
  142. recordSelected: [],
  143. formDialogType: 0,
  144. formDialogTitles: ["新增","编辑", "详情"],
  145. formDialog: false,
  146. formData: {},
  147. status: '',
  148. totalAmount: 0,
  149. workerAmount: 0,
  150. websitAmount: 0,
  151. tabIndex: 1,
  152. workerId: '',
  153. websitId: '',
  154. tabIndexShow: true,
  155. formType: 'add',
  156. formVisible: false,
  157. }
  158. },
  159. watch: {
  160. tabIndex() {
  161. this.tabIndexShow = false
  162. this.$nextTick(() => {
  163. if(this.tabIndex == 1){
  164. this.status = ''
  165. }
  166. this.tabIndexShow = true
  167. })
  168. }
  169. },
  170. computed: {
  171. // 事件组合
  172. optionsEvensGroup() {
  173. return [
  174. [
  175. [
  176. this.optionsEvensAuth("bulkSettlement", {
  177. isRole: this.tabIndex== 2,
  178. click: () => {
  179. this.batchSettleAccounts()
  180. }
  181. })
  182. ],
  183. ]
  184. ]
  185. },
  186. // 更多参数
  187. moreParameters() {
  188. return []
  189. }
  190. },
  191. methods: {
  192. // 切换状态
  193. changeType(val) {
  194. this.workerId = ''
  195. this.websitId = ''
  196. this.$refs.pageRef.refreshList()
  197. },
  198. // 列表请求函数
  199. getList(p) {
  200. try {
  201. var pam = JSON.parse(JSON.stringify(p))
  202. pam.params.push({ "param": "a.pay_type", "compare": "=", "value": 'LINE' })
  203. if (this.status && this.tabIndex==2) {
  204. pam.params.push({ "param": "a.status", "compare": "=", "value": this.status })
  205. }
  206. if(this.workerId){
  207. pam.params.push({ "param": "a.websit_id", "compare": "=", "value": this.websitId },{ "param": "a.worker_id", "compare": "=", "value": this.workerId })
  208. }
  209. return this.tabIndex==1?listPageV1(pam):listPageV2(pam)
  210. } catch (error) {
  211. console.log(error)
  212. }
  213. },
  214. // 列表导出函数
  215. exportList1: pageExport1,
  216. exportList2: pageExport2,
  217. // 表格列解析渲染数据更改
  218. columnParsing(item, defaultData) {
  219. return defaultData
  220. },
  221. // 监听勾选变化
  222. selectionChange(data) {
  223. this.recordSelected = data
  224. },
  225. openForm(type, id) {
  226. this.$refs.tabPage.addTab({
  227. // 对应显示的模块
  228. activeKey: type,
  229. // 唯一标识
  230. key: type,
  231. // 页签名称
  232. label: ({ detail: "详情" })[type],
  233. // 打开时事件
  234. triggerEvent: () => {
  235. this.formCancel()
  236. this.$nextTick(()=>{
  237. this.formType = type
  238. this.formVisible = true
  239. if (type == 'detail') {
  240. this.formDialogType = 1
  241. this.totalAmount = 0
  242. this.workerAmount = 0
  243. this.websitAmount = 0
  244. getDetail({ id }).then(res => {
  245. Object.assign(this.formData, res.data)
  246. res.data.settlementOrderItemList.forEach(item=>{
  247. this.totalAmount += (item.totalAmount*100 + this.totalAmount*100)/100
  248. this.workerAmount = (item.workerAmount*100 + this.workerAmount*100)/100
  249. this.websitAmount += (item.websitAmount*100 + this.websitAmount*100)/100
  250. })
  251. })
  252. }
  253. })
  254. },
  255. // 关闭时事件
  256. closeEvent: () => {
  257. }
  258. })
  259. },
  260. formCancel() {
  261. this.formVisible = false
  262. this.$refs?.formRef?.resetFields()
  263. this.$data.formData = this.$options.data().formData
  264. },
  265. // 表格操作列
  266. operation() {
  267. return this.operationBtn({
  268. detail: {
  269. btnType: 'text',
  270. name: ({ row, index, column }) => {
  271. return this.tabIndex==1?'查看明细':'详情'
  272. },
  273. click: ({ row, index, column }) => {
  274. if(this.tabIndex==1){
  275. this.workerId = row.workerId
  276. this.websitId = row.websitId
  277. this.tabIndex = 2
  278. this.$refs.pageRef.refreshList()
  279. }else{
  280. this.openForm('detail',row.settlementOrderId)
  281. }
  282. }
  283. },
  284. refund: {
  285. btnType: 'text',
  286. prompt: '确认是否退款?',
  287. conditions: ({ row, index, column }) => {
  288. return row.totalAmount > 0 && row.refundStatus == 'NO' && this.tabIndex==2
  289. },
  290. click: ({ row, index, column }) => {
  291. refund({ id: row.settlementOrderId }).then(res => {
  292. if (res.code == 200) {
  293. this.$message({ type: 'success', message: '退款成功!' })
  294. this.$refs.pageRef.refreshList()
  295. } else {
  296. this.$message.error(res.msg);
  297. }
  298. })
  299. }
  300. },
  301. settlement: {
  302. btnType: 'text',
  303. conditions: ({ row, index, column }) => {
  304. return row.status == 'WAIT' || this.tabIndex==1
  305. },
  306. click: ({ row, index, column }) => {
  307. if(this.tabIndex==1){
  308. this.status = 'WAIT'
  309. this.workerId = row.workerId
  310. this.websitId = row.websitId
  311. this.tabIndex = 2
  312. this.$refs.pageRef.refreshList()
  313. }else{
  314. this.settleAccounts(row.settlementOrderId)
  315. }
  316. }
  317. }
  318. })
  319. },
  320. batchSettleAccounts(){
  321. if(this.recordSelected.length == 0){
  322. return this.$message.warning('请至少勾选一条数据!');
  323. }
  324. this.settleAccounts(this.recordSelected.map(item=>{return item.settlementOrderId}).join(','))
  325. },
  326. settleAccounts(id,cancel,type){
  327. this.$confirm(`请确认是否结算选中数据, 是否继续?`, '提示', {
  328. confirmButtonText: '确定',
  329. cancelButtonText: '取消',
  330. type: 'warning'
  331. }).then(() => {
  332. settleAccounts({
  333. id
  334. }).then(res => {
  335. if (res.code == 200) {
  336. this.$message({ type: 'success', message: `结算成功!` })
  337. if(type== 2){cancel('list')}
  338. this.$refs.pageRef.refreshList()
  339. this.formDialog = false
  340. } else {
  341. this.$message.error(res.msg);
  342. }
  343. })
  344. });
  345. }
  346. }
  347. }
  348. </script>
  349. <style lang="scss" scoped>
  350. .tab{
  351. padding: 20px 20px 0 20px;
  352. }
  353. .bold{
  354. width: 160px;
  355. font-weight: bold;
  356. background-color: #f0f0f0;
  357. }
  358. </style>