index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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.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. this.workerId = ''
  166. this.websitId = ''
  167. }
  168. this.tabIndexShow = true
  169. })
  170. }
  171. },
  172. computed: {
  173. // 事件组合
  174. optionsEvensGroup() {
  175. return [
  176. [
  177. [
  178. this.optionsEvensAuth("bulkSettlement", {
  179. isRole: this.tabIndex== 2,
  180. click: () => {
  181. this.batchSettleAccounts()
  182. }
  183. })
  184. ],
  185. ]
  186. ]
  187. },
  188. // 更多参数
  189. moreParameters() {
  190. return []
  191. }
  192. },
  193. methods: {
  194. // 切换状态
  195. changeType(val) {
  196. this.workerId = ''
  197. this.websitId = ''
  198. this.$refs.pageRef.refreshList()
  199. },
  200. // 列表请求函数
  201. getList(p) {
  202. try {
  203. var pam = JSON.parse(JSON.stringify(p))
  204. pam.params.push({ "param": "a.pay_type", "compare": "=", "value": 'LINE' })
  205. if (this.status && this.tabIndex==2) {
  206. pam.params.push({ "param": "a.status", "compare": "=", "value": this.status })
  207. }
  208. if(this.workerId){
  209. pam.params.push({ "param": "a.websit_id", "compare": "=", "value": this.websitId },{ "param": "a.worker_id", "compare": "=", "value": this.workerId })
  210. }
  211. return this.tabIndex==1?listPageV1(pam):listPageV2(pam)
  212. } catch (error) {
  213. console.log(error)
  214. }
  215. },
  216. // 列表导出函数
  217. exportList1: pageExport1,
  218. exportList2: pageExport2,
  219. // 表格列解析渲染数据更改
  220. columnParsing(item, defaultData) {
  221. return defaultData
  222. },
  223. // 监听勾选变化
  224. selectionChange(data) {
  225. this.recordSelected = data
  226. },
  227. openForm(type, id) {
  228. this.$refs.tabPage.addTab({
  229. // 对应显示的模块
  230. activeKey: type,
  231. // 唯一标识
  232. key: type,
  233. // 页签名称
  234. label: ({ detail: "详情" })[type],
  235. // 打开时事件
  236. triggerEvent: () => {
  237. this.formCancel()
  238. this.$nextTick(()=>{
  239. this.formType = type
  240. this.formVisible = true
  241. if (type == 'detail') {
  242. this.formDialogType = 1
  243. this.totalAmount = 0
  244. this.workerAmount = 0
  245. this.websitAmount = 0
  246. getDetail({ id }).then(res => {
  247. Object.assign(this.formData, res.data)
  248. res.data.settlementOrderItemList.forEach(item=>{
  249. this.totalAmount += (item.totalAmount*100 + this.totalAmount*100)/100
  250. this.workerAmount = (item.workerAmount*100 + this.workerAmount*100)/100
  251. this.websitAmount += (item.websitAmount*100 + this.websitAmount*100)/100
  252. })
  253. })
  254. }
  255. })
  256. },
  257. // 关闭时事件
  258. closeEvent: () => {
  259. }
  260. })
  261. },
  262. formCancel() {
  263. this.formVisible = false
  264. this.$refs?.formRef?.resetFields()
  265. this.$data.formData = this.$options.data().formData
  266. },
  267. // 表格操作列
  268. operation() {
  269. return this.operationBtn({
  270. detail: {
  271. btnType: 'text',
  272. name: ({ row, index, column }) => {
  273. return this.tabIndex==1?'查看明细':'详情'
  274. },
  275. click: ({ row, index, column }) => {
  276. if(this.tabIndex==1){
  277. this.workerId = row.workerId
  278. this.websitId = row.websitId
  279. this.tabIndex = 2
  280. this.$refs.pageRef.refreshList()
  281. }else{
  282. this.openForm('detail',row.settlementOrderId)
  283. }
  284. }
  285. },
  286. refund: {
  287. btnType: 'text',
  288. prompt: '确认是否退款?',
  289. conditions: ({ row, index, column }) => {
  290. return row.totalAmount > 0 && row.refundStatus == 'NO' && this.tabIndex==2
  291. },
  292. click: ({ row, index, column }) => {
  293. refund({ id: row.settlementOrderId }).then(res => {
  294. if (res.code == 200) {
  295. this.$message({ type: 'success', message: '退款成功!' })
  296. this.$refs.pageRef.refreshList()
  297. } else {
  298. this.$message.error(res.msg);
  299. }
  300. })
  301. }
  302. },
  303. settlement: {
  304. btnType: 'text',
  305. conditions: ({ row, index, column }) => {
  306. return row.status == 'WAIT' || this.tabIndex==1
  307. },
  308. click: ({ row, index, column }) => {
  309. if(this.tabIndex==1){
  310. this.status = 'WAIT'
  311. this.workerId = row.workerId
  312. this.websitId = row.websitId
  313. this.tabIndex = 2
  314. this.$refs.pageRef.refreshList()
  315. }else{
  316. this.settleAccounts(row.settlementOrderId)
  317. }
  318. }
  319. }
  320. })
  321. },
  322. batchSettleAccounts(){
  323. if(this.recordSelected.length == 0){
  324. return this.$message.warning('请至少勾选一条数据!');
  325. }
  326. this.settleAccounts(this.recordSelected.map(item=>{return item.settlementOrderId}).join(','))
  327. },
  328. settleAccounts(id,cancel,type){
  329. this.$confirm(`请确认是否结算选中数据, 是否继续?`, '提示', {
  330. confirmButtonText: '确定',
  331. cancelButtonText: '取消',
  332. type: 'warning'
  333. }).then(() => {
  334. settleAccounts({
  335. id
  336. }).then(res => {
  337. if (res.code == 200) {
  338. this.$message({ type: 'success', message: `结算成功!` })
  339. if(type== 2){cancel('list')}
  340. this.$refs.pageRef.refreshList()
  341. this.formDialog = false
  342. } else {
  343. this.$message.error(res.msg);
  344. }
  345. })
  346. });
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss" scoped>
  352. .tab{
  353. padding: 20px 20px 0 20px;
  354. }
  355. .bold{
  356. width: 160px;
  357. font-weight: bold;
  358. background-color: #f0f0f0;
  359. }
  360. </style>