trainingExperience.js 1.52 KB
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
import dayjs from 'dayjs'
import api from '~/api/crew/index'
Component({
  properties: {
    detailInfo: {
      type: Object,
      value: {},
    },
  },
  data: {
		IMG_URL,
		topStats: [
			{ label: '学习时长', value: 20 },
			{ label: '完成课程数', value: 22 },
			{ label: '带教次数', value: 2 }
		],
		tabs: [
			{ key: 'course', label: '课程学习' },
			{ key: 'coach', label: '督导带教' }
		],
		activeTab: 0,
		list: []
	},
  methods: {
		search(e) {
			let { activeTab, detailInfo } = this.data
			let params = {
				storeManagerPhone: detailInfo.storeManagerPhone,
				startDate: e.detail.startDay?.replace(/\//g, '-'),
				endDate: e.detail.endDay?.replace(/\//g, '-'),
				trainingType: activeTab + 1
			}
			// 假数据
			let data = [{
				taskId: 1,
				name: '客情维护客户画像的重要性',
				completedTime: 1773739327171
			}, {
				taskId: 2,
				name: '督导带教',
				completedTime: 1773739321171
			}]
			data?.forEach(val => {
				val.completedTime = dayjs(val.completedTime).format('YYYY-MM-DD HH:mm:ss')
			})
			this.setData({list: data})
			// api.getTrainingExperienceList(params).then(res => {

			// })
		},
		onTabTap(e) {
			const { index } = e.currentTarget.dataset || {}
			if (index == this.data.activeTab) return
			this.setData({ activeTab: index })
		},
		onViewItem(e) {
			const { type, item } = e.currentTarget.dataset || {}
			this.triggerEvent('view', { type, item })
		}
	},
})