index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="客户编号" prop="customerCode">
  5. <el-input v-model="queryParams.customerCode" placeholder="请输入客户编号" clearable style="width: 250px"
  6. @keyup.enter.native="handleQuery" />
  7. </el-form-item>
  8. <el-form-item label="客户名称" prop="customerName">
  9. <el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable style="width: 250px"
  10. @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item label="成立日期" prop="registDate">
  13. <el-date-picker v-model="queryParams.registDate" style="width: 250px" value-format="yyyy-MM-dd HH:mm:ss"
  14. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
  15. :default-time="['00:00:00', '23:59:59']" />
  16. </el-form-item>
  17. <el-form-item label="联系人" prop="customerPerson">
  18. <el-input v-model="queryParams.customerPerson" placeholder="请输入客户名称" clearable style="width: 250px"
  19. @keyup.enter.native="handleQuery" />
  20. </el-form-item>
  21. <el-form-item label="手机号" prop="customerPersonPhone">
  22. <el-input v-model="queryParams.customerPersonPhone" placeholder="请输入客户名称" clearable style="width: 250px"
  23. @keyup.enter.native="handleQuery" />
  24. </el-form-item>
  25. <el-form-item label="是否开启" prop="isOpen">
  26. <el-select v-model="queryParams.isOpen" placeholder="状态" clearable style="width: 250px">
  27. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" :key="parseInt(dict.value)"
  28. :label="dict.label" :value="parseInt(dict.value)" />
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  39. v-hasPermi="['customer:info:create']">新增</el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  43. v-hasPermi="['customer:info:export']">导出</el-button>
  44. </el-col>
  45. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  46. </el-row>
  47. <el-table v-loading="loading" :data="dataList">
  48. <el-table-column label="客户编号" align="center" prop="customerCode" min-width="350" />
  49. <el-table-column label="客户名称" align="center" prop="customerName" min-width="150" />
  50. <el-table-column label="客户成立日期" align="center" prop="registDate" min-width="100" />
  51. <el-table-column label="注册资本金(万元)" align="center" prop="capital" min-width="150" />
  52. <el-table-column label="法人代表" align="center" prop="legalPerson" min-width="100" />
  53. <el-table-column label="员工人数" align="center" prop="workforce" min-width="100" />
  54. <el-table-column label="联系人" align="center" prop="customerPerson" min-width="100" />
  55. <el-table-column label="联系人手机号" align="center" prop="customerPersonPhone" min-width="150" />
  56. <el-table-column label="是否开启" align="center">
  57. <template v-slot="scope">
  58. <el-switch v-model="scope.row.isOpen" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="创建人" align="center" prop="creatorEmployeeName" min-width="100" />
  62. <el-table-column label="创建时间" align="center" prop="createTime" min-width="150">
  63. <template v-slot="scope">
  64. <span>{{ parseTime(scope.row.createTime) }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" min-width="150">
  68. <template v-slot="scope">
  69. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  70. v-hasPermi="['customer:info:update']">修改</el-button>
  71. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  72. v-hasPermi="['customer:info:delete']">删除</el-button>
  73. <el-button size="mini" type="text" icon="el-icon-detail" @click="handleDetail(scope.row)">详情</el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  78. @pagination="getList" />
  79. <!-- 添加或修改对话框 -->
  80. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  81. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  82. <el-row>
  83. <el-col :span="24">
  84. <el-form-item label="客户编号" prop="customerCode">
  85. <el-input v-model="form.customerCode" placeholder='请输入客户名称' disabled></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="24">
  89. <el-form-item label="客户名称" prop="customerName">
  90. <el-input maxlength="30" v-model="form.customerName" placeholder='请输入客户名称'></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="24">
  94. <el-form-item label="成立日期" prop="registDate">
  95. <el-date-picker value-format="yyyy-MM-dd" v-model="form.registDate" type="date" placeholder="选择日期"
  96. style="width: 100%;">
  97. </el-date-picker>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="24">
  101. <el-form-item label="注册资金" prop="capital">
  102. <el-input v-model="form.capital" placeholder='请输入注册资本金(万元)'></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="24">
  106. <el-form-item label="法人代表" prop="legalPerson">
  107. <el-input maxlength="10" v-model="form.legalPerson" placeholder='请输入法人代表'></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="24">
  111. <el-form-item label="员工人数" prop="workforce">
  112. <el-input-number v-model="form.workforce" :min="1" label="员工人数" style="width: 100%;"></el-input-number>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="24">
  116. <el-form-item label="客户地址" prop="companyAddress">
  117. <el-input maxlength="30" v-model="form.companyAddress" placeholder='请输入客户地址'></el-input>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="24">
  121. <el-form-item label="联系人" prop="customerPerson">
  122. <el-input maxlength="10" v-model="form.customerPerson" placeholder='请输入客户联系人'></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="24">
  126. <el-form-item label="手机号" prop="customerPersonPhone">
  127. <el-input v-model="form.customerPersonPhone" placeholder='请输入客户联系手机号'></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="24">
  131. <el-form-item label="办公地址" prop="companyPersonAddress">
  132. <el-input maxlength="30" v-model="form.companyPersonAddress" placeholder='请输入客户联系人办公地址'></el-input>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="24">
  136. <el-form-item label="附件">
  137. <el-upload :action="fileUrl" :headers="headers" :file-list="files" :on-success="handleFileSuccessCite"
  138. :before-upload="beforeUploadFile" :on-remove="handleRemove">
  139. <el-button size="small" type="primary">点击上传</el-button>
  140. </el-upload>
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="24">
  144. <el-form-item label="备注">
  145. <el-input maxlength="200" rows="4" show-word-limit type="textarea" v-model="form.remarks"
  146. placeholder="请输入" />
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. </el-form>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button type="primary" @click="submitForm">确 定</el-button>
  153. <el-button @click="cancel">取 消</el-button>
  154. </div>
  155. </el-dialog>
  156. <!-- 详情对话框 -->
  157. <el-dialog :title="title" :visible.sync="openDetail" width="800px" append-to-body>
  158. <div class="widget-wrapper">
  159. <div class="widget-list">
  160. <div class="fx-field x-grid-col-12">
  161. <div class="field-label">
  162. <span class="field-required">*</span>
  163. <div class="field-name">客户编号</div>
  164. </div>
  165. <div class="field-component">
  166. <span :title="form.customerCode">{{ form.customerCode }}</span>
  167. </div>
  168. </div>
  169. <div class="fx-field x-grid-col-12">
  170. <div class="field-label">
  171. <span class="field-required">*</span>
  172. <div class="field-name">客户名称</div>
  173. </div>
  174. <div class="field-component">
  175. <span :title="form.customerName">{{ form.customerName }}</span>
  176. </div>
  177. </div>
  178. <div class="fx-field x-grid-col-12">
  179. <div class="field-label">
  180. <span class="field-required">*</span>
  181. <div class="field-name">成立日期</div>
  182. </div>
  183. <div class="field-component">
  184. <span :title="form.registDate">{{ form.registDate }}</span>
  185. </div>
  186. </div>
  187. <div class="fx-field x-grid-col-12">
  188. <div class="field-label">
  189. <span class="field-required">*</span>
  190. <div class="field-name">注册资金</div>
  191. </div>
  192. <div class="field-component">
  193. <span :title="form.capital">{{ form.capital }}</span>
  194. </div>
  195. </div>
  196. <div class="fx-field x-grid-col-12">
  197. <div class="field-label">
  198. <span class="field-required">*</span>
  199. <div class="field-name">法人代表</div>
  200. </div>
  201. <div class="field-component">
  202. <span :title="form.legalPerson">{{ form.legalPerson }}</span>
  203. </div>
  204. </div>
  205. <div class="fx-field x-grid-col-12">
  206. <div class="field-label">
  207. <div class="field-name">员工人数</div>
  208. </div>
  209. <div class="field-component">
  210. <span :title="form.workforce">{{ form.workforce }}</span>
  211. </div>
  212. </div>
  213. <div class="fx-field x-grid-col-12">
  214. <div class="field-label">
  215. <span class="field-required">*</span>
  216. <div class="field-name">客户地址</div>
  217. </div>
  218. <div class="field-component">
  219. <span :title="form.companyAddress">{{ form.companyAddress }}</span>
  220. </div>
  221. </div>
  222. <div class="fx-field x-grid-col-12">
  223. <div class="field-label">
  224. <span class="field-required">*</span>
  225. <div class="field-name">联系人</div>
  226. </div>
  227. <div class="field-component">
  228. <span :title="form.customerPerson">{{ form.customerPerson }}</span>
  229. </div>
  230. </div>
  231. <div class="fx-field x-grid-col-12">
  232. <div class="field-label">
  233. <span class="field-required">*</span>
  234. <div class="field-name">手机号</div>
  235. </div>
  236. <div class="field-component">
  237. <span :title="form.customerPersonPhone">{{ form.customerPersonPhone }}</span>
  238. </div>
  239. </div>
  240. <div class="fx-field x-grid-col-12">
  241. <div class="field-label">
  242. <div class="field-name">办公地址</div>
  243. </div>
  244. <div class="field-component">
  245. <span :title="form.companyPersonAddress">{{ form.companyPersonAddress }}</span>
  246. </div>
  247. </div>
  248. <div class="fx-field x-grid-col-12">
  249. <div class="field-label">
  250. <div class="field-name">附件</div>
  251. </div>
  252. <div class="field-component">
  253. <div v-for="(item, index) in form.fileList" :key="index">
  254. <a :href="item.url" target="_blank" :title="item.name" style="color: #5094d5;">{{ item.name }}</a>
  255. </div>
  256. </div>
  257. </div>
  258. <div class="fx-field x-grid-col-12">
  259. <div class="field-label">
  260. <div class="field-name">备注</div>
  261. </div>
  262. <div class="field-component">
  263. <span :title="form.remarks">{{ form.remarks }}</span>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. </el-dialog>
  269. </div>
  270. </template>
  271. <script>
  272. import { changeUserStatus,getCustomerCode,listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer, exportCustomer } from "@/api/crm/customer";
  273. import { getBaseHeader } from "@/utils/request";
  274. import {CommonStatusEnum} from "@/utils/constants";
  275. export default {
  276. data() {
  277. return {
  278. files: [],
  279. // 设置上传的请求头部
  280. headers: getBaseHeader(),
  281. // 上传的地址
  282. fileUrl: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/uploaData',
  283. // 遮罩层
  284. loading: true,
  285. // 导出遮罩层
  286. exportLoading: false,
  287. // 显示搜索条件
  288. showSearch: true,
  289. // 总条数
  290. total: 0,
  291. // 字典表格数据
  292. dataList: [],
  293. // 弹出层标题
  294. title: "",
  295. // 是否显示弹出层
  296. open: false,
  297. openDetail: false,
  298. // 查询参数
  299. queryParams: {
  300. pageNo: 1,
  301. pageSize: 10,
  302. customerCode: undefined,
  303. customerName: undefined,
  304. registDate: [],
  305. customerPerson: undefined,
  306. customerPersonPhone: undefined,
  307. isOpen:undefined,
  308. },
  309. // 枚举
  310. SysCommonStatusEnum: CommonStatusEnum,
  311. // 表单参数
  312. form: {},
  313. // 表单校验
  314. rules: {
  315. customerCode: [
  316. { required: true, message: '请输入客户编号', trigger: 'blur' },
  317. ],
  318. customerName: [
  319. { required: true, message: '请输入客户名称', trigger: 'blur' },
  320. ],
  321. registDate: [
  322. { required: true, message: '请选择成立日期', trigger: 'blur' }
  323. ],
  324. capital: [
  325. { required: true, message: '请输入金额', trigger: 'blur' },
  326. {
  327. pattern: /^(([1-9]{1}\d{0,9})|(0{1}))(\.\d{1,2})?$/,
  328. message: "请输入合法的金额数字,最多两位小数",
  329. trigger: "blur"
  330. }
  331. ],
  332. legalPerson: [
  333. { required: true, message: '请输入法人代表', trigger: 'blur' },
  334. ],
  335. companyAddress: [
  336. { required: true, message: '请输入客户地址', trigger: 'blur' },
  337. ],
  338. customerPerson: [
  339. { required: true, message: '请输入联系人', trigger: 'blur' },
  340. ],
  341. customerPersonPhone: [
  342. {
  343. required: true,
  344. pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
  345. message: "请输入正确的手机号码",
  346. trigger: "blur"
  347. }
  348. ],
  349. },
  350. };
  351. },
  352. created() {
  353. this.getList();
  354. },
  355. methods: {
  356. getCustomerCode(){
  357. getCustomerCode().then(response => {
  358. this.form.customerCode = response.data;
  359. });
  360. },
  361. handleRemove(file, fileList) {
  362. console.log(file, fileList);
  363. let fileIds = [];
  364. for (let i in fileList) {
  365. let id = fileList[i].response.data.id;
  366. fileIds.push(id);
  367. }
  368. this.form.fileIdList = fileIds;
  369. },
  370. beforeUploadFile(file) {
  371. console.log(file);
  372. const size = file.size / 1024 / 1024;
  373. console.log(size);
  374. if (size > 5) {
  375. this.$message.error("文件大小不能超过5MB!");
  376. return false;
  377. }
  378. },
  379. handleFileSuccessCite(res, file, fileList) {
  380. console.log(file, fileList);
  381. console.log("------", "==========");
  382. console.log("res = ", res);
  383. let fileIds = [];
  384. for (let i in fileList) {
  385. let response = fileList[i].response;
  386. if (response.errno && response.errno != "0") {
  387. this.$message.error("该文件上传失败,已被移除,请重新上传!");
  388. // 上传失败移除该 file 对象
  389. fileList.splice(i, 1);
  390. } else {
  391. let id = fileList[i].response.data.id;
  392. fileIds.push(id);
  393. }
  394. }
  395. this.form.fileIdList = fileIds;
  396. },
  397. /** 查询列表 */
  398. getList() {
  399. this.loading = true;
  400. // 执行查询
  401. listCustomer(this.queryParams).then(response => {
  402. this.dataList = response.data.list;
  403. this.total = response.data.total;
  404. this.loading = false;
  405. });
  406. },
  407. // 用户状态修改
  408. handleStatusChange(row) {
  409. let text = row.isOpen === CommonStatusEnum.ENABLE ? "开启" : "关闭";
  410. this.$modal.confirm('确认要"' + text + '""' + row.customerName + '"客户吗?').then(function() {
  411. return changeUserStatus(row.id, row.isOpen);
  412. }).then(() => {
  413. this.$modal.msgSuccess(text + "成功");
  414. this.getList();
  415. }).catch(function() {
  416. row.isOpen = row.isOpen === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
  417. : CommonStatusEnum.ENABLE;
  418. });
  419. },
  420. // 取消按钮
  421. cancel() {
  422. this.open = false;
  423. this.reset();
  424. },
  425. // 表单重置
  426. reset() {
  427. this.files = [],
  428. this.form = {
  429. customerCode: undefined,
  430. customerName: undefined,
  431. registDate: undefined,
  432. capital: undefined,
  433. legalPerson: undefined,
  434. workforce: 1,
  435. companyAddress: undefined,
  436. customerPerson: undefined,
  437. customerPersonPhone: undefined,
  438. companyPersonAddress: undefined,
  439. fileIdList: undefined,
  440. remarks: undefined,
  441. };
  442. this.resetForm("form");
  443. },
  444. /** 搜索按钮操作 */
  445. handleQuery() {
  446. this.queryParams.pageNo = 1;
  447. this.getList();
  448. },
  449. /** 重置按钮操作 */
  450. resetQuery() {
  451. this.resetForm("queryForm");
  452. this.handleQuery();
  453. },
  454. /** 新增按钮操作 */
  455. handleAdd() {
  456. this.reset();
  457. this.getCustomerCode();
  458. this.open = true;
  459. this.title = "添加";
  460. },
  461. /** 详情按钮操作 */
  462. handleDetail(row) {
  463. this.reset();
  464. const id = row.id;
  465. getCustomer(id).then(response => {
  466. this.form = response.data;
  467. this.openDetail = true;
  468. this.title = "详情";
  469. });
  470. },
  471. /** 修改按钮操作 */
  472. handleUpdate(row) {
  473. this.reset();
  474. const id = row.id;
  475. getCustomer(id).then(response => {
  476. let files = response.data.fileList;
  477. if (files) {
  478. this.files = [];
  479. for (let i in files) {
  480. let url = files[i].url;
  481. let name = files[i].name;
  482. let id = files[i].id;
  483. this.files.push({
  484. name: name,
  485. url: url,
  486. response: { error: "0", data: { url: url, id: id } },
  487. });
  488. }
  489. }
  490. this.form = response.data;
  491. this.open = true;
  492. this.title = "修改";
  493. });
  494. },
  495. /** 提交按钮 */
  496. submitForm: function () {
  497. this.$refs["form"].validate(valid => {
  498. if (valid) {
  499. if (this.form.id !== undefined) {
  500. updateCustomer(this.form).then(response => {
  501. this.$modal.msgSuccess("修改成功");
  502. this.open = false;
  503. this.getList();
  504. });
  505. } else {
  506. addCustomer(this.form).then(response => {
  507. this.$modal.msgSuccess("新增成功");
  508. this.open = false;
  509. this.getList();
  510. });
  511. }
  512. }
  513. });
  514. },
  515. /** 删除按钮操作 */
  516. handleDelete(row) {
  517. const ids = row.id || this.ids;
  518. this.$modal.confirm('是否确认删除数据项?').then(function () {
  519. return delCustomer(ids);
  520. }).then(() => {
  521. this.getList();
  522. this.$modal.msgSuccess("删除成功");
  523. }).catch(() => { });
  524. },
  525. /** 导出按钮操作 */
  526. handleExport() {
  527. // 处理查询参数
  528. let params = { ...this.queryParams };
  529. params.pageNo = undefined;
  530. params.pageSize = undefined;
  531. // 执行导出
  532. this.$modal.confirm('是否确认导出所有数据项?').then(() => {
  533. this.exportLoading = true;
  534. return exportCustomer(params);
  535. }).then(response => {
  536. this.$download.excel(response, '客户信息.xls');
  537. this.exportLoading = false;
  538. }).catch(() => { });
  539. }
  540. }
  541. };
  542. </script>
  543. <style lang="scss" scoped>
  544. .widget-wrapper>.widget-list {
  545. display: flex;
  546. flex-wrap: wrap;
  547. }
  548. .x-grid-col-6 {
  549. width: 50%;
  550. }
  551. .x-grid-col-12 {
  552. width: 100%;
  553. }
  554. .fx-field {
  555. line-height: 20px;
  556. padding: 7px 12px 12px;
  557. position: relative;
  558. }
  559. .fx-field .field-label {
  560. word-wrap: break-word;
  561. color: #141e31;
  562. display: flex;
  563. font-weight: 600;
  564. line-height: 20px;
  565. padding: 5px 0;
  566. position: relative;
  567. word-break: break-word;
  568. }
  569. .fx-field .field-label .field-required {
  570. color: #eb5050;
  571. margin-left: -6px;
  572. position: relative;
  573. }
  574. .fx-field .field-label .field-name {
  575. overflow: hidden;
  576. }
  577. .field-component {
  578. word-wrap: break-word;
  579. background: #f5f6f8;
  580. border-radius: 2px;
  581. color: #141e31;
  582. font-size: 14px;
  583. line-height: 20px;
  584. min-height: 32px;
  585. padding: 6px 8px;
  586. white-space: pre-wrap;
  587. word-break: break-word;
  588. }
  589. ul {
  590. padding-left: 0px !important;
  591. }
  592. .el-tag+.el-tag {
  593. margin-left: 10px;
  594. }
  595. </style>