detail.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="w-full h-full flex flex-col">
  3. <div class="bg-white info flex-1 overflow-y-auto">
  4. <van-cell title="任务名称" :value="infoData.taskName" />
  5. <van-cell title="优先级">
  6. <template #default>
  7. {{ fixedFieldPriority.find(subItem => subItem.value == infoData.priority)?.label || '' }}
  8. </template>
  9. </van-cell>
  10. <van-cell title="状态" :value="''">
  11. <template #default>
  12. <div :style="`color: ${fixedFieldTaskStatus.find(subItem => subItem.value == infoData.status)?.color}`">
  13. {{ fixedFieldTaskStatus.find(subItem => subItem.value == infoData.status)?.label || '' }}
  14. </div>
  15. </template>
  16. </van-cell>
  17. <van-cell title="执行人">
  18. <template #default>
  19. <TranslationComponent :openId="infoData.taskExecutors" />
  20. </template>
  21. </van-cell>
  22. <van-cell title="开始时间" :value="infoData.startDate" />
  23. <van-cell title="截至时间" :value="infoData.endDate" />
  24. <van-cell title="客户名称" :value="infoData.customName" v-if="infoData.customName" />
  25. <van-cell :title="`${businessLabel}名称`" :value="infoData.businessName" v-if="infoData.businessName" />
  26. <van-cell title="销售订单" :value="infoData.orderName" v-if="infoData.orderName" />
  27. <van-cell title="线索名称" :value="infoData.clueName" v-if="infoData.clueName" />
  28. <van-cell title="联系人名称" :value="infoData.contactsName" v-if="!infoData.clueId" />
  29. <van-cell title="联系人号码" :value="infoData.contactsPhone" v-if="!infoData.clueId" />
  30. </div>
  31. <div class="bottomButton">
  32. <van-button type="success" class="w-full block" @click="completeTheTask(2)"
  33. v-if="infoData.status != 2">完成任务</van-button>
  34. <!-- <van-button type="primary" class="w-full block" @click="completeTheTask(0)" v-if="infoData.status == 2">重启任务</van-button> -->
  35. <van-button type="primary" class="w-full block" @click="restartTask()"
  36. v-if="infoData.status == 2">重启任务</van-button>
  37. <van-button type="danger" class="w-full block" @click="deleteTask">删除任务</van-button>
  38. </div>
  39. <van-popup v-model:show="showDelay" closeable position="bottom" round>
  40. <div class="newModuleAdded relative">
  41. <div class="text-size-large text-[#474A56] absolute topTitle">重启时间</div>
  42. <div class="flex flex-col overflow-y-auto h-52">
  43. <div class="flex-1">
  44. <div class="px-6 py-4 bg-[#F8F8FA] flex justify-between items-center mt-2" @click="showDatePickerCli('showStartDelayData')">
  45. <div>选择开始时间</div>
  46. <div class="flex items-center">
  47. {{ showStartDelayData }}
  48. <van-icon name="arrow" size="1.2rem" class="ml-2" />
  49. </div>
  50. </div>
  51. </div>
  52. <div class="flex-1">
  53. <div class="px-6 py-4 bg-[#F8F8FA] flex justify-between items-center mt-2" @click="showDatePickerCli('showEndtDelayData')">
  54. <div>选择结束时间</div>
  55. <div class="flex items-center">
  56. {{ showEndtDelayData }}
  57. <van-icon name="arrow" size="1.2rem" class="ml-2" />
  58. </div>
  59. </div>
  60. </div>
  61. <van-button type="primary" :disabled="showEndtDelayData < todaySDate" @click="delayTimeEvent()">重启</van-button>
  62. </div>
  63. </div>
  64. </van-popup>
  65. <van-popup v-model:show="showDatePicker" destroy-on-close position="bottom" :style="{ height: '50%' }">
  66. <van-date-picker v-model="showDatePickerVal" @confirm="showPickerConfirm" :min-date="timeJudgment" @cancel="showDatePicker = false" />
  67. </van-popup>
  68. </div>
  69. </template>
  70. <script setup>
  71. import { ref, watch } from 'vue';
  72. import { showConfirmDialog } from 'vant';
  73. import { useLifecycle } from '@hooks/useCommon.js';
  74. import { GET_TASK_DETAILS, TASK_OPERATION } from "@hooks/useApi"
  75. import requests from "@common/requests";
  76. import { fixedFieldPaymentStatus, fixedFieldPriority, fixedFieldTaskStatus, fixedFieldStatusArray } from "@utility/defaultData"
  77. import useShowToast from '@hooks/useToast'
  78. import { routingInfos } from "@utility/generalVariables"
  79. import useInfoStore from '@store/useInfoStore'
  80. import useFixedData from "@store/useFixedData.js"
  81. import useRouterStore from "@store/useRouterStore.js";
  82. import dayjs from 'dayjs';
  83. const router = useRouterStore()
  84. const fixedData = useFixedData()
  85. const userInfo = useInfoStore()
  86. const { toastSuccess, toastLoading, toastFail, toastText, clearToast } = useShowToast()
  87. const props = defineProps({
  88. info: {
  89. type: Object,
  90. required: true,
  91. default: () => ({})
  92. }
  93. })
  94. const routingInformation = routingInfos['tasks']
  95. const infoData = ref(props.info);
  96. const timeout = ref(null);
  97. const showDelay = ref(false);
  98. const showDatePicker = ref(false);
  99. const showDatePickerVal = ref([])
  100. const todaySDate = dayjs(new Date()).format('YYYY-MM-DD')
  101. const showStartDelayData = ref('');
  102. const showEndtDelayData = ref('');
  103. const showDateType = ref('');
  104. const timeJudgment = ref(new Date())
  105. const isExistBusiness = sessionStorage.getItem("isExistBusiness");
  106. const businessLabel = isExistBusiness === "1" ? "商机" : "项目";
  107. watch(() => props.info, (newValue) => {
  108. initializeData(newValue.id)
  109. })
  110. function showPickerConfirm({ selectedValues }) {
  111. const dates = selectedValues.join('-')
  112. if(showDateType.value == 'showStartDelayData') {
  113. showStartDelayData.value = dates
  114. showEndtDelayData.value = ''
  115. }
  116. if(showDateType.value == 'showEndtDelayData') {
  117. showEndtDelayData.value = dates
  118. }
  119. console.log(showStartDelayData.value)
  120. console.log(showEndtDelayData.value)
  121. showDatePicker.value = false
  122. }
  123. function showDatePickerCli(type) {
  124. showDateType.value = type
  125. const types = type == 'showStartDelayData' ? showStartDelayData.value : showEndtDelayData.value
  126. timeJudgment.value = type == 'showStartDelayData' ? new Date : new Date(showStartDelayData.value)
  127. showDatePickerVal.value = types.split('-')
  128. showDatePicker.value = true
  129. }
  130. function restartTask() {
  131. showStartDelayData.value = infoData.value.startDate ? infoData.value.startDate : dayjs().format("YYYY-MM-DD")
  132. showEndtDelayData.value = infoData.value.endDate ? infoData.value.endDate : dayjs().format("YYYY-MM-DD")
  133. showDelay.value = true
  134. }
  135. function delayTimeEvent() {
  136. const id = infoData.value.id
  137. requests.post(TASK_OPERATION, { id, status: 0, startDate: showStartDelayData.value, endDate: showEndtDelayData.value }).then(({ data }) => {
  138. toastSuccess('操作成功')
  139. showDelay.value = false
  140. getTaskDetails(id)
  141. })
  142. }
  143. function completeTheTask(status) {
  144. const id = infoData.value.id
  145. requests.post(TASK_OPERATION, { id, status }).then(({ data }) => {
  146. toastSuccess('操作成功')
  147. getTaskDetails(id)
  148. })
  149. }
  150. function deleteTask() {
  151. const { name = '', searchFiled = {}, deteleFiled = '' } = routingInformation
  152. const row = infoData.value
  153. const foemVal = { [routingInformation.key == 'tasks' ? 'taskIds' : 'ids']: row.id }
  154. showConfirmDialog({
  155. title: `删除${name}`,
  156. message: `确定删除【${row[searchFiled?.search]}】${name}吗?`,
  157. }).then(() => {
  158. requests.post(deteleFiled, { ...foemVal }).then((res) => {
  159. toastSuccess('删除成功')
  160. router.navigateBack({
  161. success: () => {
  162. router.emit('moduleListDetailParameter', {
  163. row: JSON.stringify(routingInformation)
  164. })
  165. }
  166. })
  167. }).catch((err) => {
  168. toastFail(err.msg ? err.msg : '删除失败')
  169. })
  170. })
  171. }
  172. function getTaskDetails(id) {
  173. requests.post(GET_TASK_DETAILS, { id }).then(({ data }) => {
  174. infoData.value = data
  175. }).finally(() => {
  176. setTimeout(() => {
  177. clearToast()
  178. }, 200)
  179. })
  180. }
  181. function initializeData(id) {
  182. clearTimeout(timeout.value);
  183. toastLoading('加载中...', 0)
  184. timeout.value = setTimeout(() => {
  185. getTaskDetails(id)
  186. }, 100);
  187. }
  188. useLifecycle({
  189. load: () => {
  190. initializeData(props.info.id)
  191. },
  192. init: () => {
  193. initializeData(props.info.id)
  194. },
  195. unLoad: () => {
  196. clearTimeout(timeout.value);
  197. }
  198. });
  199. </script>
  200. <style lang='scss' scoped>
  201. .bottomButton {
  202. margin: 0 14px;
  203. padding-bottom: 30px;
  204. :deep(.van-button) {
  205. margin-bottom: 20px;
  206. }
  207. }
  208. .info {
  209. margin: 8px 14px 30px 14px;
  210. }
  211. .newModuleAdded {
  212. padding: 45px 25px 45px 25px;
  213. }
  214. .topTitle {
  215. top: 14px;
  216. }
  217. .boxLxr {
  218. max-height: 180px;
  219. }
  220. </style>