index.vue 12 KB

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