index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="商机名称" prop="name">
  6. <el-input v-model="queryParams.name" placeholder="请输入商机名称" clearable @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  10. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  11. </el-form-item>
  12. </el-form>
  13. <!-- 操作工具栏 -->
  14. <el-row :gutter="10" class="mb8">
  15. <el-col :span="1.5">
  16. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  17. v-hasPermi="['crm:business:create']">新增</el-button>
  18. </el-col>
  19. <el-col :span="1.5">
  20. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  21. v-hasPermi="['crm:business:export']">导出</el-button>
  22. </el-col>
  23. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  24. </el-row>
  25. <!-- 列表 -->
  26. <el-table v-loading="loading" :data="list">
  27. <el-table-column label="商机名称" align="center" prop="name" />
  28. <el-table-column label="客户名称" align="center" prop="customerId" />
  29. <el-table-column label="商机金额" align="center" prop="price" />
  30. <el-table-column label="预计成交日期" align="center" prop="dealTime" width="180">
  31. <template v-slot="scope">
  32. <span>{{ parseTime(scope.row.dealTime) }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="备注" align="center" prop="remark" />
  36. <el-table-column label="商机状态类型" align="center" prop="statusTypeId" width="120">
  37. <template v-slot="scope">
  38. <el-tag> {{getBusinessStatusTypeName(scope.row.statusTypeId)}} </el-tag>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="商机状态" align="center" prop="statusId" width="100">
  42. <template v-slot="scope">
  43. <el-tag> {{getBusinessStatusName(scope.row.statusId)}} </el-tag>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
  47. <template v-slot="scope">
  48. <span>{{ parseTime(scope.row.updateTime) }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  52. <template v-slot="scope">
  53. <span>{{ parseTime(scope.row.createTime) }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="负责人" align="center" prop="ownerUserId" />
  57. <el-table-column label="创建人" align="center" prop="creator" />
  58. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  59. <template v-slot="scope">
  60. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  61. v-hasPermi="['crm:business:update']">修改</el-button>
  62. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  63. v-hasPermi="['crm:business:delete']">删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <!-- 分页组件 -->
  68. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  69. @pagination="getList"/>
  70. <!-- 对话框(添加 / 修改) -->
  71. <el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
  72. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  73. <el-form-item label="商机名称" prop="name">
  74. <el-input v-model="form.name" placeholder="请输入商机名称" />
  75. </el-form-item>
  76. <el-form-item label="客户编号" prop="customerId">
  77. <el-input v-model="form.customerId" placeholder="请输入客户编号" />
  78. </el-form-item>
  79. <el-form-item label="商机状态类型" prop="statusTypeId">
  80. <el-select v-model="form.statusTypeId" placeholder="请选择商机状态类型" clearable size="small" @change="changeBusinessStatusType">
  81. <el-option v-for="item in businessStatusTypeList" :key="item.id" :label="item.name" :value="item.id"/>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item label="商机状态" prop="statusId">
  85. <el-select v-model="form.statusId" placeholder="请选择商机状态" clearable size="small">
  86. <el-option v-for="item in businessStatusList" :key="item.id" :label="item.name" :value="item.id"/>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item label="预计成交日期" prop="dealTime">
  90. <el-date-picker clearable v-model="form.dealTime" type="date" value-format="timestamp" placeholder="选择预计成交日期" />
  91. </el-form-item>
  92. <el-form-item label="商机金额" prop="price">
  93. <el-input v-model="form.price" placeholder="请输入商机金额" />
  94. </el-form-item>
  95. <el-form-item label="整单折扣(%)" prop="discountPercent">
  96. <el-input v-model="form.discountPercent" placeholder="请输入整单折扣" />
  97. </el-form-item>
  98. <el-form-item label="产品总金额" prop="productPrice">
  99. <el-input v-model="form.productPrice" placeholder="请输入产品总金额" />
  100. </el-form-item>
  101. <el-form-item label="备注" prop="remark">
  102. <el-input v-model="form.remark" placeholder="请输入备注" />
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="submitForm">确 定</el-button>
  107. <el-button @click="cancel">取 消</el-button>
  108. </div>
  109. </el-dialog>
  110. </div>
  111. </template>
  112. <script>
  113. import { createBusiness, updateBusiness, deleteBusiness, getBusiness, getBusinessPage, exportBusinessExcel } from "@/api/crm/business";
  114. import { getBusinessStatusListByTypeId, getBusinessStatusList } from "@/api/crm/businessStatus";
  115. import { getBusinessStatusTypeList } from "@/api/crm/businessStatusType";
  116. export default {
  117. name: "Business",
  118. components: {
  119. },
  120. data() {
  121. return {
  122. // 遮罩层
  123. loading: true,
  124. // 导出遮罩层
  125. exportLoading: false,
  126. // 显示搜索条件
  127. showSearch: true,
  128. // 总条数
  129. total: 0,
  130. // 商机列表
  131. list: [],
  132. // 根据类型ID获取的商机状态列表
  133. businessStatusList: [],
  134. // 所有商机状态列表
  135. businessStatusAllList: [],
  136. // 商机状态类型列表
  137. businessStatusTypeList: [],
  138. // 弹出层标题
  139. title: "",
  140. // 是否显示弹出层
  141. open: false,
  142. // 查询参数
  143. queryParams: {
  144. pageNo: 1,
  145. pageSize: 10,
  146. name: null,
  147. statusTypeId: null,
  148. statusId: null,
  149. contactNextTime: [],
  150. customerId: null,
  151. dealTime: [],
  152. price: null,
  153. discountPercent: null,
  154. productPrice: null,
  155. remark: null,
  156. ownerUserId: null,
  157. createTime: [],
  158. roUserIds: null,
  159. rwUserIds: null,
  160. endStatus: null,
  161. endRemark: null,
  162. contactLastTime: [],
  163. followUpStatus: null,
  164. },
  165. // 表单参数
  166. form: {},
  167. // 表单校验
  168. rules: {
  169. name: [{ required: true, message: "商机名称不能为空", trigger: "blur" }],
  170. customerId: [{ required: true, message: "客户编号不能为空", trigger: "blur" }],
  171. roUserIds: [{ required: true, message: "只读权限的用户编号数组不能为空", trigger: "blur" }],
  172. rwUserIds: [{ required: true, message: "读写权限的用户编号数组不能为空", trigger: "blur" }],
  173. endStatus: [{ required: true, message: "1赢单2输单3无效不能为空", trigger: "blur" }],
  174. }
  175. };
  176. },
  177. created() {
  178. this.getList();
  179. },
  180. methods: {
  181. /** 查询列表 */
  182. getList() {
  183. this.loading = true;
  184. // 执行查询
  185. getBusinessPage(this.queryParams).then(response => {
  186. this.list = response.data.list;
  187. this.total = response.data.total;
  188. this.loading = false;
  189. });
  190. //查询商机状态类型集合
  191. getBusinessStatusTypeList().then(response => {
  192. this.businessStatusTypeList = response.data;
  193. });
  194. //查询商机状态类型集合
  195. getBusinessStatusList().then(response => {
  196. this.businessStatusAllList = response.data;
  197. });
  198. },
  199. /** 取消按钮 */
  200. cancel() {
  201. this.open = false;
  202. this.reset();
  203. },
  204. /** 表单重置 */
  205. reset() {
  206. this.form = {
  207. id: undefined,
  208. name: undefined,
  209. statusTypeId: undefined,
  210. statusId: undefined,
  211. contactNextTime: undefined,
  212. customerId: undefined,
  213. dealTime: undefined,
  214. price: undefined,
  215. discountPercent: undefined,
  216. productPrice: undefined,
  217. remark: undefined,
  218. ownerUserId: undefined,
  219. roUserIds: undefined,
  220. rwUserIds: undefined,
  221. endStatus: undefined,
  222. endRemark: undefined,
  223. contactLastTime: undefined,
  224. followUpStatus: undefined,
  225. };
  226. this.resetForm("form");
  227. },
  228. /** 搜索按钮操作 */
  229. handleQuery() {
  230. this.queryParams.pageNo = 1;
  231. this.getList();
  232. },
  233. /** 重置按钮操作 */
  234. resetQuery() {
  235. this.resetForm("queryForm");
  236. this.handleQuery();
  237. },
  238. /** 新增按钮操作 */
  239. handleAdd() {
  240. this.reset();
  241. this.open = true;
  242. this.title = "添加商机";
  243. },
  244. /** 修改按钮操作 */
  245. handleUpdate(row) {
  246. this.reset();
  247. const id = row.id;
  248. getBusiness(id).then(response => {
  249. this.form = response.data;
  250. this.open = true;
  251. this.title = "修改商机";
  252. });
  253. },
  254. /** 提交按钮 */
  255. submitForm() {
  256. this.$refs["form"].validate(valid => {
  257. if (!valid) {
  258. return;
  259. }
  260. // 修改的提交
  261. if (this.form.id != null) {
  262. updateBusiness(this.form).then(response => {
  263. this.$modal.msgSuccess("修改成功");
  264. this.open = false;
  265. this.getList();
  266. });
  267. return;
  268. }
  269. // 添加的提交
  270. createBusiness(this.form).then(response => {
  271. this.$modal.msgSuccess("新增成功");
  272. this.open = false;
  273. this.getList();
  274. });
  275. });
  276. },
  277. /** 删除按钮操作 */
  278. handleDelete(row) {
  279. const id = row.id;
  280. this.$modal.confirm('是否确认删除商机编号为"' + id + '"的数据项?').then(function() {
  281. return deleteBusiness(id);
  282. }).then(() => {
  283. this.getList();
  284. this.$modal.msgSuccess("删除成功");
  285. }).catch(() => {});
  286. },
  287. /** 导出按钮操作 */
  288. handleExport() {
  289. // 处理查询参数
  290. let params = {...this.queryParams};
  291. params.pageNo = undefined;
  292. params.pageSize = undefined;
  293. this.$modal.confirm('是否确认导出所有商机数据项?').then(() => {
  294. this.exportLoading = true;
  295. return exportBusinessExcel(params);
  296. }).then(response => {
  297. this.$download.excel(response, '商机.xls');
  298. this.exportLoading = false;
  299. }).catch(() => {});
  300. },
  301. /** 选择商机状态类型事件 */
  302. changeBusinessStatusType (id) {
  303. //查询商机状态集合
  304. getBusinessStatusListByTypeId(id).then(response => {
  305. this.businessStatusList = response.data;
  306. });
  307. },
  308. /** 商机状态类型名格式化 */
  309. getBusinessStatusTypeName(typeId) {
  310. for (const item of this.businessStatusTypeList) {
  311. if (item.id === typeId) {
  312. return item.name;
  313. }
  314. }
  315. return '未知';
  316. },
  317. /** 商机状态名格式化 */
  318. getBusinessStatusName(id) {
  319. for (const item of this.businessStatusAllList) {
  320. if (item.id === id) {
  321. return item.name;
  322. }
  323. }
  324. return '未知';
  325. }
  326. }
  327. };
  328. </script>