index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="h-full flex">
  3. <div class="p-5 w-80 pr-0">
  4. <div class="bg-white w-full h-full shadow-md rounded-md flex flex-col">
  5. <div class="flex-1 p-3 overflow-y-auto">
  6. <el-form :model="businessOpportunityForm" label-width="70px" style="max-width: 600px">
  7. <el-form-item label="商机名称">
  8. <el-input v-model="businessOpportunityForm.name" clearable placeholder="请输入"></el-input>
  9. </el-form-item>
  10. <el-form-item label="商机阶段">
  11. <el-select v-model="businessOpportunityForm.stageId" placeholder="请选择">
  12. <el-option v-for="item in fixedData.BusinessStage" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="客户名称">
  16. <el-input v-model="businessOpportunityForm.customerName" clearable placeholder="请输入"></el-input>
  17. </el-form-item>
  18. <el-form-item label="联系人">
  19. <el-input v-model="businessOpportunityForm.contactPerson" clearable placeholder="请输入"></el-input>
  20. </el-form-item>
  21. <el-form-item label="产品">
  22. <el-select v-model="businessOpportunityForm.product" placeholder="请选择">
  23. <el-option v-for="item in fixedData.Personnel" :key="item.id" :label="item.name" :value="item.id" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="负责人">
  27. <el-select v-model="businessOpportunityForm.inchargerId" placeholder="请选择">
  28. <el-option v-for="item in fixedData.Personnel" :key="item.id" :label="item.name" :value="item.id" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="创建时间">
  32. <el-date-picker v-model="businessOpportunityForm.startTime" type="date" placeholder="请选择" :clearable="false"
  33. format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  34. </el-form-item>
  35. <el-form-item label="">
  36. <el-date-picker v-model="businessOpportunityForm.endTime" type="date" placeholder="请选择" :clearable="false"
  37. format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  38. </el-form-item>
  39. </el-form>
  40. </div>
  41. <div class="w-full flex p-3 shadow-[0_-3px_5px_0px_rgba(0,0,0,0.2)]">
  42. <El-button class="w-full">重置</El-Button>
  43. <El-button type="primary" class="w-full">搜索</El-Button>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="flex-1 p-5 overflow-auto">
  48. <div class="bg-white w-full h-full p-3 shadow-md rounded-md flex flex-col">
  49. <div class="flex justify-end pb-3">
  50. <el-button type="primary" @click="showVisible('newBusinessisible')">新建商机</el-button>
  51. <el-button type="primary">批量转移</el-button>
  52. <el-button type="primary">批量删除</el-button>
  53. <el-button type="primary">阶段设置</el-button>
  54. <el-button type="primary">回收站</el-button>
  55. <el-button type="primary">导入</el-button>
  56. <el-button type="primary">导出</el-button>
  57. </div>
  58. <div class="flex-1 w-full overflow-hidden">
  59. <el-table ref="clueTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
  60. style="width: 100%;height: 100%;">
  61. <el-table-column type="selection" width="55" />
  62. <el-table-column prop="name" label="商机名称" width="180">
  63. <template #default="scope">
  64. <el-button link type="primary" size="large" @click="toBusinessTableDetail(scope.row)">{{
  65. scope.row.name
  66. }}</el-button>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="clueSourceId" label="客户名称" width="180"></el-table-column>
  70. <el-table-column prop="phone" label="联系人" width="180">
  71. <template #default="scope">
  72. <el-button link type="primary" size="large">{{
  73. scope.row.phone
  74. }}</el-button>
  75. </template>
  76. </el-table-column>
  77. <el-table-column prop="email" label="商机金额" width="180"></el-table-column>
  78. <el-table-column prop="customerIndustryId" label="商机阶段" width="180"></el-table-column>
  79. <el-table-column prop="customerLevelId" label="预计成交" width="180"></el-table-column>
  80. <el-table-column prop="inchargerId" label="负责人" width="180"></el-table-column>
  81. <el-table-column prop="createName" label="创建人" width="180"></el-table-column>
  82. <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
  83. <el-table-column label="操作" fixed="right" width="200">
  84. <template #default="scope">
  85. <el-button link type="primary" size="large">编辑</el-button>
  86. <el-button link type="primary" size="large">新建任务</el-button>
  87. <el-button link type="danger" size="large">删除</el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </div>
  92. <div class="flex justify-end pt-3">
  93. <el-pagination layout="total, prev, pager, next, sizes" :total="businessTotalTable"
  94. :hide-on-single-page="true" />
  95. </div>
  96. </div>
  97. </div>
  98. <!-- 弹窗 -->
  99. <el-dialog v-model="allVisible.newBusinessisible" width="1000" :show-close="false" top="10vh"
  100. :before-close="handleClose">
  101. <template #header="{ close, titleId, titleClass }">
  102. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  103. <h4 :id="titleId">{{ allText.newBusinessisibleText }}</h4>
  104. <div>
  105. <el-button type="primary">保存并新建</el-button>
  106. <el-button type="primary" @click="editBusiness()">保存</el-button>
  107. <el-button @click="closeVisible('newBusinessisible')">取消</el-button>
  108. </div>
  109. </div>
  110. </template>
  111. <div class="h-[60vh] overflow-y-auto scroll-bar">
  112. <!-- <GenerateForm ref="generateForm" :data="generateFormData" /> -->
  113. <div>相关产品</div>
  114. <RelatedProducts :productTableList="productTableList" />
  115. </div>
  116. </el-dialog>
  117. </div>
  118. </template>
  119. <script lang="ts" setup>
  120. import { ref, reactive, onMounted, inject } from "vue";
  121. import type { FormInstance, FormRules } from 'element-plus'
  122. import { useRouter, useRoute } from "vue-router";
  123. import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM } from './api'
  124. import { GETTABLELIST } from '@/pages/product/api'
  125. import { post, get } from "@/utils/request";
  126. import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate } from '@/utils/tools'
  127. import { GenerateForm } from '@zmjs/form-design';
  128. import RelatedProducts from './component/relatedProducts.vue'
  129. const route = useRoute()
  130. const router = useRouter()
  131. const globalPopup = inject<GlobalPopup>('globalPopup')
  132. const businessTotalTable = ref(0)
  133. const generateForm = ref<typeof GenerateForm>() // 自定义表单dom
  134. const generateFormData = ref({
  135. config: {},
  136. list: []
  137. }) // 自定义表单数据
  138. const businessTable = ref([
  139. { name: '商机040101', phone: '张山' }
  140. ])
  141. const allLoading = reactive<AllLoadingInterface>({
  142. businessTableLading: false
  143. })
  144. const allVisible = reactive<AllVisibleInterface>({
  145. newBusinessisible: false,
  146. recycleVisible: false,
  147. })
  148. const allText = reactive({
  149. newBusinessisibleText: '新建商机'
  150. }) // 所有文本
  151. const businessOpportunityForm = reactive<businessOpportunityFormType>({
  152. name: '',
  153. stageId: '',
  154. customerName: '',
  155. contactPerson: '',
  156. product: '',
  157. inchargerId: '',
  158. startTime: getFirstDayOfMonth(new Date()),
  159. endTime: formatDate(new Date()),
  160. pageIndex: 1,
  161. pageFrom: 10
  162. })
  163. const fixedData = reactive({
  164. BusinessStage: [] as fixedDataInterface[],
  165. Personnel: [] as personnelInterface[]
  166. })
  167. const productTableList = ref([])
  168. function editBusiness() {
  169. generateForm.value?.getData().then((res: any) => {
  170. console.log('正确')
  171. console.log(res)
  172. }).catch((_err: any) => {
  173. globalPopup?.showError('请填写完整')
  174. })
  175. }
  176. function showVisible(type: keyof AllVisibleInterface) { // 显示弹窗
  177. allVisible[type] = true
  178. }
  179. function closeVisible(type: keyof AllVisibleInterface) {
  180. allVisible[type] = false
  181. }
  182. function handleClose(done: () => void) {
  183. done()
  184. }
  185. async function getSystemField() {
  186. const systemField = getAllListByCode(['商机阶段'])
  187. for (let i in systemField) {
  188. const { data } = await get(`${GETSYSFILED}?code=${systemField[i]}`)
  189. for (let key of Object.keys(fixedData)) {
  190. if (systemField[i] == key) {
  191. Object.assign(fixedData, { [key]: data })
  192. }
  193. }
  194. }
  195. const { data } = await post(GETPERSONNEL, {})
  196. fixedData.Personnel = data.map((item: any) => {
  197. const { id, name, phone, jobNumber } = item
  198. return {
  199. id, name, phone, jobNumber
  200. }
  201. })
  202. const res = await get(GETGENERATEFOEM)
  203. generateFormData.value = JSON.parse(res.data[0].config)
  204. }
  205. function toBusinessTableDetail(row: any) {
  206. console.log('点击跳转详情')
  207. router.push({
  208. path: `${MOD}/detail`,
  209. query: { id: row.id }
  210. })
  211. }
  212. function getProductTableList() {
  213. post(GETTABLELIST, { pageIndex: -1, pageSize: -1 }).then((res) => {
  214. if (res.code == 'ok') {
  215. const { record, total } = res.data
  216. productTableList.value = record.map((item: any) => {
  217. const { id, productName, productCode, unit, unitName, typeName, type, price, inventory } = item
  218. return {
  219. productId: id,
  220. productName,
  221. productCode,
  222. unit,
  223. unitName,
  224. price,
  225. type,
  226. typeName,
  227. inventory,
  228. quantity: '',
  229. discount: '',
  230. totalPrice: ''
  231. }
  232. })
  233. }
  234. })
  235. }
  236. onMounted(() => {
  237. getSystemField()
  238. getProductTableList()
  239. })
  240. </script>
  241. <style lang="scss" scoped>
  242. .dialog-header {
  243. h4 {
  244. font-size: 18px;
  245. line-height: 24px;
  246. }
  247. }
  248. </style>