Commit 1db5e3034e38d8731b399ca5cbff2c452a22c658

Authored by 史婷婷
1 parent 70369de3

feat: 客户信息-详情&启用&停用

@@ -40,3 +40,27 @@ export function updateApi(params) { @@ -40,3 +40,27 @@ export function updateApi(params) {
40 contentType: ContentTypeEnum.FORM_URLENCODED 40 contentType: ContentTypeEnum.FORM_URLENCODED
41 }) 41 })
42 } 42 }
  43 +
  44 +// 停用
  45 +export function unableApi(id) {
  46 + return request({
  47 + url: baseUrl + '/unable',
  48 + method: 'patch',
  49 + data: {
  50 + id
  51 + },
  52 + contentType: ContentTypeEnum.FORM_URLENCODED
  53 + })
  54 +}
  55 +
  56 +// 启用
  57 +export function enableApi(id) {
  58 + return request({
  59 + url: baseUrl + '/enable',
  60 + method: 'patch',
  61 + data: {
  62 + id
  63 + },
  64 + contentType: ContentTypeEnum.FORM_URLENCODED
  65 + })
  66 +}
@@ -122,6 +122,14 @@ @@ -122,6 +122,14 @@
122 } 122 }
123 }, 123 },
124 { 124 {
  125 + "path": "pages/customer/detail",
  126 + "style": {
  127 + "navigationBarTitleText": "客户信息详情",
  128 + "navigationBarBackgroundColor": "#ffffff",
  129 + "navigationBarTextStyle": "black"
  130 + }
  131 + },
  132 + {
125 "path": "pages/credit_manage/index", 133 "path": "pages/credit_manage/index",
126 "style": { 134 "style": {
127 "navigationBarTitleText": "客户资信管理", 135 "navigationBarTitleText": "客户资信管理",
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <view class="section">
  6 + <text class="row company">{{ form.name }}</text>
  7 + <view class="row"><text class="label">编号</text><text class="value">{{ form.code }}</text></view>
  8 + <view class="row"><text class="label">状态</text><text class="value">{{ form.available ? '启用' : '停用' }}</text>
  9 + </view>
  10 + <view class="row"><text class="label">联系人</text><text class="value">{{ form.contact }}</text></view>
  11 + <view class="row"><text class="label">联系电话</text><text class="value">{{ form.telephone }}</text></view>
  12 + <view class="row"><text class="label">电子邮箱</text><text class="value">{{ form.email }}</text></view>
  13 + <view class="row"><text class="label">邮编</text><text class="value">{{ form.zipCode }}</text></view>
  14 + <view class="row"><text class="label">传真</text><text class="value">{{ form.fax }}</text></view>
  15 + <view class="row"><text class="label">地区</text><text class="value">{{ form.cityName }}</text></view>
  16 + <view class="row"><text class="label">地址</text><text class="value">{{ form.address }}</text></view>
  17 + </view>
  18 +
  19 + <view class="title-header">
  20 + <image class="title-header_icon" src="/static/images/title.png" />
  21 + <span>详细信息</span>
  22 + </view>
  23 + <view class="section">
  24 + <view class="row"><text class="label">统一社会信用代码</text><text class="value">{{ form.creditCode }}</text></view>
  25 + <view class="row"><text class="label">纳税人识别号</text><text class="value">{{ form.taxIdentifyNo }}</text></view>
  26 + <view class="row"><text class="label">开户银行</text><text class="value">{{ form.bankName }}</text></view>
  27 + <view class="row"><text class="label">户名</text><text class="value">{{ form.accountName }}</text></view>
  28 + <view class="row"><text class="label">银行账号</text><text class="value">{{ form.accountNo }}</text></view>
  29 + </view>
  30 +
  31 + <view class="title-header">
  32 + <image class="title-header_icon" src="/static/images/title.png" />
  33 + <span>其他信息</span>
  34 + </view>
  35 + <view class="section">
  36 + <view class="row"><text class="label">备注</text><text class="value">{{ form.description }}</text></view>
  37 + </view>
  38 +
  39 + </view>
  40 + </scroll-view>
  41 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  42 + </view>
  43 +</template>
  44 +
  45 +<script>
  46 +import { getDetailApi, unableApi, enableApi } from '@/api/customer.js'
  47 +import DetailButtons from '@/components/detail-buttons/index.vue'
  48 +
  49 +export default {
  50 + name: 'CustomerDetail',
  51 + components: { DetailButtons },
  52 + data() {
  53 + return {
  54 + form: {},
  55 + buttons: [
  56 + { text: '编辑', visible: true, variant: 'primary', event: 'edit' },
  57 + { text: '启用', visible: true, variant: 'outline', event: 'enable' },
  58 + { text: '停用', visible: true, variant: 'outline', event: 'disable', style: { color: 'rgba(0,0,0,0.9)', border: '1px solid #DCDCDC' } },
  59 + ]
  60 + }
  61 + },
  62 + computed: {
  63 + displayButtons() {
  64 + const available = this.form.available
  65 + return [
  66 + { ...this.buttons[0], visible: this.$auth.hasPermi('base-data:customer:modify') },
  67 + { ...this.buttons[1], visible: !available },
  68 + { ...this.buttons[2], visible: !!available }
  69 + ]
  70 + }
  71 + },
  72 + onLoad(query) {
  73 + const id = (query && (query.id || query.code)) || ''
  74 + if (id) this.loadDetail(id)
  75 + },
  76 + methods: {
  77 + async loadDetail(id) {
  78 + try {
  79 + const res = await getDetailApi(id)
  80 + this.form = res.data || {}
  81 + } catch (e) {
  82 + this.form = {}
  83 + }
  84 + },
  85 + handleButtonClick(btn) {
  86 + if (!btn || btn.disabled) return
  87 + const map = {
  88 + edit: () => this.onEdit(),
  89 + enable: () => this.onEnable(),
  90 + disable: () => this.onDisable()
  91 + }
  92 + const fn = map[btn.event]
  93 + if (typeof fn === 'function') fn()
  94 + },
  95 + onEdit() {
  96 + const id = this.form.id || this.form.code
  97 + if (!id) return
  98 + const query = '?id=' + encodeURIComponent(id)
  99 + uni.navigateTo({ url: '/pages/customer/modify' + query })
  100 + },
  101 + onEnable() {
  102 + const id = this.form.id
  103 + if (!id) return
  104 + uni.showModal({
  105 + title: '系统提示',
  106 + content: '是否确定启用?',
  107 + success: (res) => {
  108 + if (res.confirm) {
  109 + enableApi(id).then(() => {
  110 + uni.showToast({ title: '已启用', icon: 'success' })
  111 + setTimeout(() => { uni.redirectTo({ url: '/pages/customer/index' }) }, 300)
  112 + }).catch(() => {
  113 + uni.showToast({ title: '启用失败', icon: 'none' })
  114 + })
  115 + }
  116 + }
  117 + })
  118 + },
  119 + onDisable() {
  120 + const id = this.form.id
  121 + if (!id) return
  122 + uni.showModal({
  123 + title: '系统提示',
  124 + content: '是否确定停用?',
  125 + success: (res) => {
  126 + if (res.confirm) {
  127 + unableApi(id).then(() => {
  128 + uni.showToast({ title: '已停用', icon: 'success' })
  129 + setTimeout(() => { uni.redirectTo({ url: '/pages/customer/index' }) }, 300)
  130 + }).catch(() => {
  131 + uni.showToast({ title: '停用失败', icon: 'none' })
  132 + })
  133 + }
  134 + }
  135 + })
  136 + }
  137 + }
  138 +}
  139 +</script>
  140 +
  141 +<style lang="scss" scoped>
  142 +.page {
  143 + display: flex;
  144 + flex-direction: column;
  145 + height: 100vh;
  146 +}
  147 +
  148 +.scroll {
  149 + flex: 1;
  150 + background: #f3f3f3;
  151 +}
  152 +
  153 +.detail-page {
  154 + padding-bottom: 40rpx;
  155 +}
  156 +
  157 +.section {
  158 + padding: 32rpx;
  159 + background: #fff;
  160 + margin-bottom: 20rpx;
  161 + position: relative;
  162 +}
  163 +
  164 +.row {
  165 + display: flex;
  166 + margin-bottom: 28rpx;
  167 +
  168 + &:last-child {
  169 + margin-bottom: 0;
  170 + }
  171 +
  172 + &.company {
  173 + font-size: 36rpx;
  174 + font-weight: 600;
  175 + color: rgba(0, 0, 0, 0.9);
  176 + padding-top: 10rpx;
  177 + margin-bottom: 32rpx;
  178 + line-height: 50rpx;
  179 + }
  180 +
  181 + .label {
  182 + width: 240rpx;
  183 + line-height: 32rpx;
  184 + font-size: 28rpx;
  185 + color: rgba(0, 0, 0, 0.6);
  186 + }
  187 +
  188 + .value {
  189 + flex: 1;
  190 + line-height: 32rpx;
  191 + font-size: 28rpx;
  192 + color: rgba(0, 0, 0, 0.9);
  193 + text-align: right;
  194 + word-break: break-all;
  195 + }
  196 +}
  197 +
  198 +.title-header {
  199 + background-color: #fff;
  200 + display: flex;
  201 + align-items: center;
  202 + padding: 32rpx 32rpx 22rpx;
  203 + border-bottom: 1rpx dashed #f0f0f0;
  204 +
  205 + &_icon {
  206 + width: 32rpx;
  207 + height: 28rpx;
  208 + margin-right: 16rpx;
  209 + }
  210 +
  211 + span {
  212 + color: rgba(0, 0, 0, 0.9);
  213 + font-size: 32rpx;
  214 + line-height: 44rpx;
  215 + font-weight: 600;
  216 + }
  217 +}
  218 +</style>
@@ -233,7 +233,7 @@ @@ -233,7 +233,7 @@
233 if (!id) return 233 if (!id) return
234 const query = '?id=' + encodeURIComponent(id) 234 const query = '?id=' + encodeURIComponent(id)
235 uni.navigateTo({ 235 uni.navigateTo({
236 - url: '/pages/credit_manage/detail' + query 236 + url: '/pages/customer/detail' + query
237 }) 237 })
238 }, 238 },
239 239