<template>
    <AppLayout :title="title" :show-bg-image="false" >
		<view class="info-box">
			<view class="info-item info-line">
				<image class="info-img" :src="baseUrl+'/dispatch/person-icon.png'" mode=""></image>
				<view class="info-label">
					人员姓名
				</view>
				<view class="info-value">
					王小美
				</view>
			</view>
			<view class="info-item">
				<image class="info-img" :src="baseUrl+'/dispatch/help-icon.png'" mode=""></image>
				<view class="info-label">
					帮扶类型
				</view>
				<view class="info-value">
					招聘岗位推荐
				</view>
			</view>
		</view>
        <view class="main-list" :style="getBackgroundStyle('k.png')">
			<view class="list-top">
				<view class="list-title">
					<text>新增跟进记录</text>
					<view class="title-line"></view>
				</view>
			</view>
			
            <view class="form-container">
                <uni-forms ref="formRef" v-model="formData" :rules="rules" validate-trigger="submit" >
                  <!-- 跟进日期 -->
                  <uni-forms-item label="跟进日期：" name="followDate" required >
					  <uni-datetime-picker class="picker-value" type="date" placeholder="请选择跟进日期"  v-model="formData.followDate" @change="onDateChange" />
                  </uni-forms-item>
            
                  <!-- 跟进方式 -->
                  <uni-forms-item label="跟进方式：" name="followMethod" required >
					  <uni-data-select v-model="formData.followMethod" placeholder="请选择跟进方式" :localdata="followMethods" @change="onMethodChange"></uni-data-select>
                  </uni-forms-item>
            
                  <!-- 跟进内容 -->
                  <uni-forms-item label="跟进内容：" name="followContent" required>
					  <uni-easyinput type="textarea" v-model="formData.followContent" placeholder="请输入跟进内容"></uni-easyinput>
                  </uni-forms-item>
            
                  <!-- 跟进结果 -->
                  <uni-forms-item label="跟进结果：" name="followResult" required>
					  <uni-easyinput type="textarea" v-model="formData.followResult" placeholder="请输入跟进结果"></uni-easyinput>
                  </uni-forms-item>
            
                  <!-- 下一步计划 -->
                  <uni-forms-item label="下一步计划：" name="nextPlan">
					  <uni-easyinput type="textarea" v-model="formData.nextPlan" placeholder="请输入下一步计划（可选）"></uni-easyinput>
                  </uni-forms-item>
            
                  <!-- 下次联系时间 -->
                  <uni-forms-item label="下次联系：" name="nextContactDate" >
					  <uni-datetime-picker class="picker-value" type="date" placeholder="请选择跟进日期"  v-model="formData.nextContactDate" @change="onDateChange" />
                  </uni-forms-item>
                </uni-forms>
            
                <!-- 按钮组 -->
                <view class="button-group">
				  <button class="btn submit-btn" @click="handleSubmit">保存跟进</button>
                  <button class="btn reset-btn"  @click="handleReset">重置</button>
                </view>
			</view>
        </view>
		<view class="main-list" :style="getBackgroundStyle('k.png')">
			<view class="list-top">
				<view class="list-title">
					<text>跟进历史记录</text>
					<view class="title-line"></view>
				</view>
				<view class="title-total">
					共<text class="total-num">7</text>条记录
				</view>
			</view>
			<view class="list-box" >
				<uni-steps :options="list2" active-color="#007AFF" :active="active" direction="column" />
			</view>
		</view>
    </AppLayout>
</template>

<script setup>
import { inject, ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
const { $api, navTo, navBack } = inject('globalFunction');
import config from "@/config.js"

const title = ref('');
const formData = reactive({
  followDate: '',
  followMethod: '',
  followContent: '',
  followResult: '',
  nextPlan: '',
  nextContactDate: ''
})
const followMethods =  [{
	"value": 0,
	"text": "电话"
}, {
	"value": 1,
	"text": "面谈"
}, {
	"value": 2,
	"text": "微信"
}, {
	"value": 3,
	"text": "邮件"
}]
const list2=[{
	title: '买家下单',
	desc: '跟进方式：电话\n跟进人：新生社区管理员\n跟进内容：内容内容内容'
}, {
	title: '卖家发货',
	desc: '跟进方式：电话\n跟进人：新生社区管理员\n跟进内容：内容内容内容'
}, {
	title: '买家签收',
	desc: '跟进方式：电话\n跟进人：新生社区管理员\n跟进内容：内容内容内容'
}, {
	title: '交易完成',
	desc: '跟进方式：电话\n跟进人：新生社区管理员\n跟进内容：内容内容内容'
}]
const active=ref(null)
// 表单引用
const formRef = ref(null)

// 校验规则
const rules = {
	followDate: {
		rules: [{
			required: true,
			errorMessage: '请选择跟进日期'
		}]
	},
	followMethod: {
		rules: [{
			required: true,
			errorMessage: '请选择跟进方式'
		}]
	},
	followContent: {
		rules: [{
			required: true,
			errorMessage: '请填写跟进内容'
		}]
	},
	followResult: {
		rules: [{
			required: true,
			errorMessage: '请填写跟进结果'
		}]
	}
}
const baseUrl = config.imgBaseUrl
const getBackgroundStyle = (imageName) => ({
    backgroundImage: `url(${baseUrl}/dispatch/${imageName})`,
    backgroundSize: 'cover',      // 覆盖整个容器
    backgroundPosition: 'center', // 居中
    backgroundRepeat: 'no-repeat'
});
const trainVideoImgUrl=config.trainVideoImgUrl


// 事件处理
const onDateChange = (field, e) => {
  formData[field] = e.detail.value
}

const onMethodChange = (e) => {
}

const handleSubmit = () => {
  formRef.value?.validate()
    .then(() => {
      uni.showToast({ title: '校验通过', icon: 'success' });
    })
    .catch((errors) => {
      console.log('校验失败:', errors);
      uni.showToast({ title: '请填写必填项', icon: 'none' });
    });
};

const handleReset = () => {
}
onLoad(() => {
});


</script>

<style lang="stylus" scoped>
image
  height: 100%
  width: 100%
.info-box
  margin: 30rpx 30rpx
  background: linear-gradient(0deg, #D9ECFF 0%, #F0F7FF 100%)
  border-radius: 20rpx
  padding: 40rpx 0
  display: flex
  align-items: center
.info-img
  width: 40rpx
  height: 40rpx
  margin-bottom: 20rpx
.info-line
  border-right: 2rpx solid #B7D6FF
.info-item
  display: flex
  flex-direction: column
  align-items: center
  justify-content: center
  width: 50%
.info-label
  font-size: 26rpx
  color: #6E7E9B
  margin-bottom: 20rpx
.info-value
  font-weight: bold
  font-size: 28rpx
  color: #3D61AC
.main-list
  background-color: #ffffff
  padding: 20rpx 20rpx 28rpx 20rpx
  margin: 30rpx 30rpx
  box-shadow: 0px 3px 20px 0px rgba(0,105,234,0.1)
  border-radius: 12px
.list-top
  display: flex
  align-items: center
  justify-content: space-between
.list-title
  font-weight: bold
  font-size: 36rpx
  color: #404040
  position: relative

.title-line
  position: absolute
  bottom: -10rpx
  left: 70rpx
  width: 70rpx
  height: 8rpx
  background: linear-gradient(90deg, #FFAD58 0%, #FF7A5B 100%)
  border-radius: 4rpx
.title-total
  font-size: 24rpx
  color: #999999
.total-num
  color: #3088FF
  margin-left: 4rpx
  margin-right: 4rpx
  font-weight: bold
  font-size: 26rpx

.label
  width: 160rpx
  font-size: 28rpx
  color: #404040

.input,
.picker
  flex: 1

.picker-value
  color: #666
.list-box
  margin-top: 40rpx

.form-container 
  margin-top: 30rpx
:deep(.uni-forms-item__label)
  width: 194rpx !important
  font-size: 28rpx;
  color: #404040;

.button-group {
  display: flex;
  justify-content: space-between;
  padding: 40rpx 20rpx 20rpx;
}

.btn {
  width: 45%;
  height: 80rpx;
  font-size: 30rpx;
  border-radius: 8rpx;
}

.reset-btn {
  background-color: #D8E9FF;
  color: #1176FF;
}

.submit-btn {
  background-color: #368BFF;
  color: white;
}
:deep(.uni-steps__column-circle )
  width: 24rpx !important
  height: 24rpx !important
  background: radial-gradient(circle, 
    #00C0FA 0%, 
    #015EEA 50%, 
    #FFFFFF 51%,  
    #FFFFFF 100%) !important
  border-radius: 50%
  border: 2rpx solid #015EEA
:deep(.uni-steps__column-title)
  font-size: 28rpx !important
  color: #006CFF !important
  margin-bottom: 24rpx
:deep(.uni-steps__column-desc)
  font-size: 28rpx
  color: #898989 !important
  line-height: 1.5
:deep(.uni-steps__column-text )
  padding: 16rpx 0 !important
  border: none
:deep(.uni-steps__column-line)
  background-color: #368BFF !important
:deep(.uni-steps__column-line--before)
  background-color:rgba(0,0,0,0) !important
:deep(.uni-date-x)
  background: rgba(0,0,0,0) !important
:deep(.uni-stat-box)
  background: rgba(0,0,0,0) !important
:deep(.uni-easyinput__content)
  background: rgba(0,0,0,0) !important
</style>
