index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="h-full flex p-3 flex-col businessDetail" v-loading="allLoading.skeletonLoading">
  3. <div class="w-full bg-white p-2 mb-2 shadow-md rounded-md flex items-center">
  4. <div class="icon mr-4">
  5. <el-link :underline="false" @click="backPath()">
  6. <el-icon class="el-icon--right"><icon-view /></el-icon> 返回商机列表
  7. </el-link>
  8. </div>
  9. <div class="mr-8">
  10. <el-select v-model="optionVal" placeholder="请选择" style="width: 250px" filterable @change="selectChange()">
  11. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  12. </el-select>
  13. </div>
  14. <div class="flex-1 flex h-full justify-end overflow-auto scroll-bar-hide cursor-pointer" @wheel="handleScroll">
  15. <div
  16. :class="`${index === 0 ? 'startStep' : 'nextStep'} ${(currentStage >= index || businessInfo.stageValue == '赢单') ? 'selected' : (currentStage >= index || businessInfo.stageValue == '输单') ? 'backOrange' : 'backGray'} relative rounded-md flex items-center pl-6 pr-6`"
  17. v-for="(item, index) in stageList" :key="index">
  18. <div class="pr-3 text-nowrap">{{ item.name }}</div>
  19. <div class="text-nowrap">{{ item.plan }}</div>
  20. </div>
  21. </div>
  22. <div class="relative rounded-md flex items-center itemPing backGray endStep item pl-6 pr-6 mr-4 resetStyle"
  23. v-if="currentStage >= 0">
  24. <el-select v-model="stageStatusVal" placeholder="结束" style="width: 100px" class="selectClas"
  25. @change="advanceChange()">
  26. <el-option v-for="(item, index) in stageListOption" :key="index" :label="item.label" :value="item.value" />
  27. </el-select>
  28. </div>
  29. <div
  30. class="relative rounded-md flex items-center justify-around backOrange endStep item pl-6 pr-6 mr-4 resetStyle"
  31. v-if="businessInfo.stageValue == '输单'" style="padding-top: 6px;padding-bottom: 6px;">
  32. <div>{{ businessInfo.stageValue }}</div>
  33. <div class="ml-5">0%</div>
  34. </div>
  35. <div class="relative rounded-md flex items-center justify-around backWan endStep item pl-6 pr-6 mr-4 resetStyle"
  36. v-if="businessInfo.stageValue == '赢单'" style="padding-top: 6px;padding-bottom: 6px;">
  37. <div>{{ businessInfo.stageValue }}</div>
  38. <div class="ml-4"> 100%</div>
  39. </div>
  40. <div class="relative rounded-md flex items-center justify-around backGray endStep item pl-6 pr-6 mr-4 resetStyle"
  41. v-if="businessInfo.stageValue == '无效'" style="padding-top: 6px;padding-bottom: 6px;">
  42. <div>{{ businessInfo.stageValue }}</div>
  43. <div class="ml-5">0%</div>
  44. </div>
  45. <div class="bg-[#075985] rounded-md text itemPing pl-2 pr-2 flex items-center aloneText"
  46. v-if="currentStage != -1">
  47. <!-- <el-link :underline="false" v-if="(currentStage + 1) != stageList.length"
  48. @click="advancementStage(false)">推进至下个阶段【{{ stageList[currentStage +
  49. 1]?.name }}】</el-link> -->
  50. <el-link :underline="false" v-if="(currentStage + 1) != stageList.length"
  51. @click="advancementStageNext(false)">推进至下个阶段【{{ stageList[currentStage +
  52. 1]?.name }}】</el-link>
  53. <el-link :underline="false" v-else class="ml-4 mr-4" @click="advancementStage(true)">赢单</el-link>
  54. </div>
  55. </div>
  56. <!-- 内容 -->
  57. <div class="flex-1 flex flex-col overflow-y-auto overflow-x-hidden scroll-bar">
  58. <div class="w-full h-auto flex justify-between">
  59. <div class="bg-white shadow-md rounded-md" style="width: 46%;">
  60. <Information :information="businessInfo" @refreshData="refreshData" />
  61. </div>
  62. <div class="bg-white ml-2 shadow-md rounded-md flex-1">
  63. <Attachment :information="businessInfo" @refreshData="refreshData" />
  64. </div>
  65. </div>
  66. <div class="w-full h-auto flex justify-between mt-2">
  67. <div class="bg-white shadow-md rounded-md" style="width: 65%;">
  68. <DetailCompinents :data="detailCompinentsData" :information="businessInfo" :formTaskType="1"
  69. :filed="'businessOpportunityId'" :disabledList="['taskType', 'businessOpportunityId']"
  70. @refreshData="getDetail" />
  71. </div>
  72. <div class="bg-white ml-2 shadow-md rounded-md flex-1">
  73. <OperationRecord :information="businessInfo" />
  74. </div>
  75. </div>
  76. <div class="w-full h-auto flex justify-between mt-2">
  77. <div class="bg-white shadow-md rounded-md w-full">
  78. <Products :information="businessInfo" @refreshData="getDetail" />
  79. </div>
  80. </div>
  81. </div>
  82. <!-- 弹窗 -->
  83. <el-dialog v-model="allVisible.advanceVisible" width="800" :show-close="false" top="10vh">
  84. <template #header="{ close, titleId, titleClass }">
  85. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  86. <h4 :id="titleId">{{ allText.advanceText }}原因</h4>
  87. <div>
  88. <el-button type="primary" :loading="allLoading.advanceSaveLoading" @click="advanceSave(true)">保存</el-button>
  89. <el-button @click="advanceClose">取消</el-button>
  90. </div>
  91. </div>
  92. </template>
  93. <div class="pt-3">
  94. <div>请输入{{ allText.advanceText }}原因</div>
  95. <el-input v-model.trim="advanceVal" style="width: 100%" class="pb-3" :placeholder="'请输入'" clearable />
  96. </div>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script lang="ts" setup>
  101. import { ref, reactive, onMounted, inject } from "vue";
  102. import type { FormInstance, FormRules } from 'element-plus'
  103. import { Edit, ArrowLeft as IconView } from '@element-plus/icons-vue'
  104. import { backPath } from '@/utils/tools'
  105. import { useRoute } from "vue-router";
  106. import { BUSIESS_ALL, BUSIESS_GETSATE, BUSIESS_INFO, URL_SAVEREASON, URL_STAGEIDNEXT } from '../api'
  107. import Information from '../component/information.vue'
  108. import Attachment from '../component/attachment.vue'
  109. // import RelatedTasks from '../component/relatedTasks.vue';
  110. import DetailCompinents from '@/components/detailcompinents/relatedTasks.vue'
  111. import OperationRecord from '../component/operationRecord.vue';
  112. import Products from '../component/products.vue';
  113. import { post } from "@/utils/request";
  114. type stageListType = {
  115. name: string,
  116. plan: string,
  117. id?: number,
  118. }
  119. const route = useRoute()
  120. const globalPopup = inject<GlobalPopup>('globalPopup')
  121. const detailCompinentsData = ref([])
  122. const optionVal = ref<any>('')
  123. const stageStatusVal = ref<any>('')
  124. const stageStatusValOriginally = ref('')
  125. const advanceVal = ref('')
  126. const options = ref<optionType[]>([])
  127. const currentStage = ref<any>('') // 当前阶段的下标
  128. const allLoading = reactive({
  129. skeletonLoading: false,
  130. advanceSaveLoading: false
  131. })
  132. const allVisible = reactive({
  133. advanceVisible: false
  134. })
  135. const allText = reactive({
  136. advanceText: ''
  137. })
  138. const businessInfo = ref<any>({})
  139. const stageListOption = ref<optionType[]>([])
  140. const stageList = ref<stageListType[]>([])
  141. function refreshData() {
  142. getDetail()
  143. }
  144. function advancementStage(flag: boolean) {
  145. console.log('点击了推进阶段')
  146. if (!flag) {
  147. allLoading.advanceSaveLoading = true
  148. advancementStageNext(true)
  149. return
  150. }
  151. let val = stageListOption.value.find((item: any) => item.label == '赢单')
  152. stageStatusVal.value = Number(val?.value || '')
  153. advanceChange()
  154. }
  155. function advanceChange() {
  156. stageStatusValOriginally.value = JSON.parse(JSON.stringify(stageStatusVal.value))
  157. const item: any = stageListOption.value.find((item) => item.value === stageStatusVal.value)
  158. console.log(item)
  159. if (item.plan == '0%') {
  160. advanceVal.value = ''
  161. allText.advanceText = item.label
  162. allVisible.advanceVisible = true
  163. return
  164. }
  165. console.log(item, '<=====')
  166. allLoading.skeletonLoading = true
  167. post(URL_STAGEIDNEXT, {
  168. id: businessInfo.value.id,
  169. stageId: item.value,
  170. stageValue: item.label,
  171. }).then((_res) => {
  172. globalPopup?.showSuccess('操作成功')
  173. selectChange()
  174. }).finally(() => {
  175. setTimeout(() => {
  176. allLoading.skeletonLoading = false
  177. }, 500)
  178. })
  179. }
  180. function advanceClose() {
  181. stageStatusVal.value = stageStatusValOriginally.value
  182. allVisible.advanceVisible = false
  183. }
  184. function advanceSave(flag: boolean) {
  185. if (!advanceVal.value && flag) {
  186. globalPopup?.showError(`请输入${allText.advanceText}原因`)
  187. return
  188. }
  189. console.log(flag)
  190. if (flag) {
  191. allLoading.advanceSaveLoading = true
  192. advancementStageNext(true)
  193. return
  194. }
  195. }
  196. function loseOrder() {
  197. post(URL_SAVEREASON, {
  198. id: businessInfo.value.id,
  199. reason: advanceVal.value
  200. }).then((_res) => {
  201. globalPopup?.showSuccess('操作成功')
  202. selectChange()
  203. }).finally(() => {
  204. allLoading.advanceSaveLoading = false
  205. allVisible.advanceVisible = false
  206. })
  207. }
  208. function advancementStageNext(flag: boolean = false) {
  209. let fromVal = {}
  210. if (!flag) {
  211. fromVal = {
  212. id: businessInfo.value.id,
  213. stageId: stageList.value[currentStage.value + 1].id,
  214. stageValue: stageList.value[currentStage.value + 1].name,
  215. }
  216. } else {
  217. const item: any = stageListOption.value.find((item) => item.value === stageStatusVal.value)
  218. fromVal = {
  219. id: businessInfo.value.id,
  220. stageId: item.value,
  221. stageValue: item.label,
  222. }
  223. }
  224. post(URL_STAGEIDNEXT, { ...fromVal }).then((_res) => {
  225. if (!flag) {
  226. globalPopup?.showSuccess('操作成功')
  227. selectChange()
  228. } else {
  229. loseOrder()
  230. }
  231. }).catch(() => {
  232. allLoading.advanceSaveLoading = false
  233. allVisible.advanceVisible = false
  234. })
  235. }
  236. function getDetail() {
  237. allLoading.skeletonLoading = true
  238. post(BUSIESS_INFO, { id: optionVal.value }).then(({ data }) => {
  239. businessInfo.value = (data || []);
  240. detailCompinentsData.value = data.taskList || []
  241. setStageIndex()
  242. }).finally(() => {
  243. allLoading.skeletonLoading = false
  244. })
  245. }
  246. function handleScroll(event: any) { // 滚表横向滚动
  247. if (event.deltaY) {
  248. event.preventDefault();
  249. const element = event.currentTarget;
  250. element.scrollLeft += event.deltaY;
  251. }
  252. }
  253. function getOptionAll() {
  254. post(BUSIESS_ALL, {}).then((res) => {
  255. const { data } = res
  256. options.value = (data || []).map((item: any) => ({
  257. value: item.id + '',
  258. label: item.name
  259. }))
  260. })
  261. }
  262. function getSatge() {
  263. post(BUSIESS_GETSATE, {}).then(({ data }) => {
  264. stageList.value = (data || []).sort((a: any, b: any) => { return a.seq - b.seq; }).filter((item: any) => !item.isFinish).map((item: any) => ({ name: item.name, plan: item.plan, id: item.id }))
  265. stageListOption.value = (data || []).sort((a: any, b: any) => { return a.seq - b.seq; }).filter((item: any) => item.isFinish).map((item: any) => ({ label: item.name, value: item.id, plan: item.plan }))
  266. setStageIndex()
  267. })
  268. }
  269. function selectChange() {
  270. getDetail()
  271. }
  272. function setStageIndex() {
  273. currentStage.value = stageList.value.findIndex((item: any) => item.id == businessInfo.value.stageId)
  274. }
  275. onMounted(() => {
  276. const { id } = route.query
  277. optionVal.value = id
  278. getDetail()
  279. getOptionAll()
  280. getSatge()
  281. setTimeout(() => {
  282. setStageIndex()
  283. }, 500)
  284. })
  285. </script>
  286. <style lang="scss" scoped>
  287. .businessDetail {
  288. .selected {
  289. background-color: #075985 !important;
  290. color: #fff !important;
  291. }
  292. .icon {
  293. .el-link {
  294. color: #0052CC;
  295. }
  296. }
  297. .text {
  298. .el-link {
  299. color: #fff;
  300. font-size: 14px;
  301. }
  302. }
  303. .backDarkBlue {
  304. background-color: #0052CC;
  305. color: #fff;
  306. }
  307. .backGray {
  308. background-color: #F4F5F7;
  309. color: #606266;
  310. }
  311. .backOrange {
  312. background-color: #FF5531;
  313. color: #fff;
  314. }
  315. .backWan {
  316. background-color: #075985;
  317. color: #fff;
  318. }
  319. .startStep {
  320. clip-path: polygon(0% 0%,
  321. 90% 0%,
  322. 100% 50%,
  323. 90% 100%,
  324. 0% 100%);
  325. }
  326. .nextStep {
  327. clip-path: polygon(0% 0%,
  328. 90% 0%,
  329. 100% 50%,
  330. 90% 100%,
  331. 0% 100%,
  332. 10% 50%);
  333. }
  334. .endStep {
  335. clip-path: polygon(0% 0%,
  336. 100% 0%,
  337. 100% 100%,
  338. 0% 100%,
  339. 10% 50%);
  340. }
  341. .itemPing {
  342. padding-top: 4px;
  343. padding-bottom: 4px;
  344. }
  345. .aloneText {
  346. padding-top: 9px;
  347. padding-bottom: 9px;
  348. }
  349. }
  350. </style>
  351. <style lang="scss">
  352. .resetStyle {
  353. .el-select__wrapper {
  354. background-color: #F4F5F7;
  355. box-shadow: none !important;
  356. }
  357. }
  358. </style>