create.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <s-layout
  3. :title="state.reason===1?'话术调整':(state.reason===2?'任务调整':'任务创建')"
  4. navbar="normal"
  5. showBackButton
  6. :bgStyle="{ color: '#FAFAFA' }"
  7. >
  8. <uni-forms
  9. ref="taskFormRef"
  10. v-model="state.model"
  11. :rules="rules"
  12. validateTrigger="bind"
  13. labelWidth="360"
  14. labelAlign="left"
  15. label-position="top"
  16. :labelStyle="{ fontWeight: 'bold' }"
  17. >
  18. <view class="form_box">
  19. <template v-if="state.reason===1">
  20. <uni-forms-item name="typeId" label="电访任务类型:" class="form-item">
  21. <uni-data-select
  22. v-model="state.model.typeId"
  23. :border="false"
  24. :clear="false"
  25. :localdata="state.taskType"
  26. @change="change"
  27. ></uni-data-select>
  28. </uni-forms-item>
  29. </template>
  30. <template v-else-if="state.reason===2">
  31. <uni-forms-item name="name" label="任务名称:" class="form-item">
  32. <uni-easyinput
  33. v-model="state.model.name"
  34. placeholder="请输入本次任务的名称"
  35. :maxlength="12"
  36. :inputBorder="false"
  37. :clearable="false"
  38. placeholderStyle="color:#999999;font-size:28rpx;font-weight:400;line-height:normal"
  39. />
  40. </uni-forms-item>
  41. <uni-forms-item name="planTime" label="任务执行时间:" class="textarea-item">
  42. <uni-datetime-picker type="datetime" hide-second :border="false" :clear-icon="false" v-model="state.model.planTime" :start="state.startTime" @change="changeLog" @show="showDatetimePicker" />
  43. </uni-forms-item>
  44. </template>
  45. <template v-else>
  46. <uni-forms-item name="name" label="任务名称:" class="form-item">
  47. <uni-easyinput
  48. v-model="state.model.name"
  49. placeholder="请输入本次任务的名称"
  50. :maxlength="12"
  51. :inputBorder="false"
  52. :clearable="false"
  53. placeholderStyle="color:#999999;font-size:28rpx;font-weight:400;line-height:normal"
  54. />
  55. </uni-forms-item>
  56. <uni-forms-item name="typeId" label="电访任务类型:" class="form-item">
  57. <uni-data-select
  58. v-model="state.model.typeId"
  59. :border="false"
  60. :clear="false"
  61. :localdata="state.taskType"
  62. @change="change"
  63. ></uni-data-select>
  64. </uni-forms-item>
  65. <uni-forms-item name="planTime" label="任务执行时间:" class="textarea-item">
  66. <uni-datetime-picker type="datetime" hide-second :border="false" :clear-icon="false" v-model="state.model.planTime" :start="state.startTime" @change="changeLog" @show="showDatetimePicker" />
  67. </uni-forms-item>
  68. </template>
  69. </view>
  70. </uni-forms>
  71. <view class="submit_btn" @click="submitForm">{{state.reason===1?'接听测试电话':(state.reason===2?'开始执行任务':'下一步')}}</view>
  72. </s-layout>
  73. </template>
  74. <script setup>
  75. import { ref, reactive, unref, computed } from 'vue'
  76. import sheep from '@/common'
  77. import { onLoad } from '@dcloudio/uni-app'
  78. import taskApi from '@/common/api/member/task'
  79. import { formatDate } from '@/common/helper/utils'
  80. const taskFormRef = ref(null);
  81. const state = reactive({
  82. showRegion: false,
  83. model: {
  84. name: '',
  85. typeId: '',
  86. planTime: '',
  87. },
  88. taskType: [],
  89. startTime:null,
  90. timer: null,
  91. reason:null,
  92. })
  93. const rules = {
  94. name: {
  95. rules: [
  96. {
  97. required: true,
  98. errorMessage: '请输入任务名称',
  99. },
  100. ],
  101. },
  102. typeId: {
  103. rules: [
  104. {
  105. required: true,
  106. errorMessage: '请选择电访任务类型',
  107. },
  108. ],
  109. },
  110. planTime: {
  111. rules: [
  112. {
  113. required: true,
  114. errorMessage: '请选择任务执行时间',
  115. },
  116. ],
  117. },
  118. }
  119. const taskFormInfo = computed(() => sheep.$store('task').taskFormInfo)
  120. onLoad(async (options) => {
  121. state.reason = Number(options.reason||null)
  122. if(!state.reason){
  123. sheep.$store('task').resetTaskData()
  124. }
  125. state.model = {
  126. name: taskFormInfo.value.name,
  127. typeId: taskFormInfo.value.typeId,
  128. callPlatform: taskFormInfo.value.callPlatform,
  129. planTime: taskFormInfo.value.planTime||formatDate(new Date().getTime()+10*60*1000, 'YYYY-MM-DD HH:mm')
  130. }
  131. getTaskType()
  132. })
  133. function showDatetimePicker(){
  134. state.startTime = new Date().getTime()+10*60*1000
  135. }
  136. function closeDatetimePicker(){
  137. console.log('closeDatetimePicker')
  138. }
  139. const change = (e) => {
  140. console.log("e:", e)
  141. state.taskType.forEach(item=>{
  142. if(item.value===e){
  143. state.model.callPlatform = item.callPlatform
  144. }
  145. })
  146. }
  147. const changeLog = (e) => {
  148. console.log('change事件:', e);
  149. }
  150. async function submitForm(){
  151. const validate = await unref(taskFormRef).validate().catch((error) => {
  152. console.log('error: ', error)
  153. })
  154. if (!validate) return
  155. sheep.$store('task').updateTaskFormInfo(state.model)
  156. if(state.reason===1){
  157. sheep.$router.go('/pages/task/speechTest',{
  158. isTest:true
  159. })
  160. } else if(state.reason===2){
  161. const { code, data } = await taskApi.addTask({
  162. ...taskFormInfo.value,
  163. planTime: taskFormInfo.value.planTime+':00'
  164. })
  165. if (code === 1) {
  166. sheep.$store('task').resetTaskData()
  167. sheep.$router.go('/pages/index/index')
  168. }
  169. } else{
  170. sheep.$router.go('/pages/task/executionList')
  171. }
  172. }
  173. async function getTaskType(){
  174. const { code, data } = await taskApi.taskType()
  175. if (code === 1) {
  176. state.taskType = (data.records||[]).map(item=>{
  177. return {
  178. value: item.id,
  179. text: item.name,
  180. callPlatform: item.callPlatform
  181. }
  182. })
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .form_box{
  188. padding: 40rpx 30rpx;
  189. }
  190. :deep() {
  191. .uni-forms-item__inner{
  192. padding-bottom: 40rpx;
  193. }
  194. .uni-forms-item__label {
  195. height: 60rpx;
  196. padding: 0 0 20rpx 0;
  197. .label-text {
  198. font-size: 28rpx !important;
  199. color: #222222 !important;
  200. font-weight: bold;
  201. }
  202. }
  203. .uni-easyinput__content-input {
  204. font-size: 28rpx;
  205. color: #222222;
  206. line-height: 100rpx;
  207. font-weight: 500;
  208. height: 100rpx;
  209. background: #fff;
  210. border-radius: 20rpx;
  211. padding: 0 20rpx !important;
  212. }
  213. .uni-stat__select{
  214. .uni-stat-box{
  215. border-radius: 20rpx;
  216. }
  217. }
  218. .uni-select{
  219. height: 100rpx;
  220. border: none;
  221. padding: 0 20rpx !important;
  222. border-radius: 20rpx;
  223. .uni-select__input-box{
  224. height: 100rpx;
  225. .uni-select__input-text{
  226. font-weight: 500;
  227. font-size: 28rpx;
  228. color: #222222;
  229. }
  230. .uni-select__input-placeholder{
  231. font-weight: 400;
  232. color: #999999;
  233. }
  234. }
  235. }
  236. .uni-date-x{
  237. padding: 0 20rpx;
  238. border-radius: 20rpx;
  239. flex-direction: row-reverse;
  240. }
  241. .uni-date__x-input{
  242. height: 100rpx;
  243. line-height: 100rpx;
  244. font-size: 28rpx;
  245. .uni-input-placeholder{
  246. font-weight: 400;
  247. color: #999999;
  248. }
  249. .uni-input-input{
  250. font-weight: 500;
  251. color: #222222;
  252. }
  253. }
  254. .uni-date__icon-clear{
  255. top: 10rpx;
  256. border: 18rpx solid transparent;
  257. }
  258. .uniui-bottom{
  259. font-size: 36rpx !important;
  260. }
  261. .uniui-top{
  262. font-size: 36rpx !important;
  263. }
  264. .uniui-clear{
  265. font-size: 48rpx !important;
  266. }
  267. .uni-error-message .uni-error-message-text{
  268. color: #FF4E4E;
  269. line-height: 40rpx;
  270. font-size: 24rpx;
  271. }
  272. }
  273. .submit_btn{
  274. width: 630rpx;
  275. height: 104rpx;
  276. line-height: 104rpx;
  277. background: #35E89A;
  278. border-radius: 40rpx;
  279. font-weight: bold;
  280. font-size: 32rpx;
  281. color: #222222;
  282. text-align: center;
  283. position: fixed;
  284. left: calc(50%);
  285. transform: translateX(-50%);
  286. bottom: 40rpx;
  287. }
  288. </style>