index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="公司名" prop="companyId">
  5. <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名" @change="companyChange" clearable size="small">
  6. <el-option
  7. v-for="item in companys"
  8. :key="item.companyId"
  9. :label="item.companyName"
  10. :value="item.companyId"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item >
  15. <treeselect style="width: 220px" :clearable="false" v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  16. </el-form-item>
  17. <el-form-item label="客户编码" prop="customerCode">
  18. <el-input
  19. v-model="queryParams.customerCode"
  20. placeholder="请输入客户编码"
  21. clearable
  22. size="small"
  23. @keyup.enter.native="handleQuery" />
  24. </el-form-item>
  25. <el-form-item label="客户名称" prop="customerName">
  26. <el-input
  27. v-model="queryParams.customerName"
  28. placeholder="请输入客户名称"
  29. clearable
  30. size="small"
  31. @keyup.enter.native="handleQuery"
  32. />
  33. </el-form-item>
  34. <el-form-item label="认领人" prop="companyUserNickName">
  35. <el-input
  36. v-model="queryParams.companyUserNickName"
  37. placeholder="请输入认领人"
  38. clearable
  39. size="small"
  40. @keyup.enter.native="handleQuery"
  41. />
  42. </el-form-item>
  43. <el-form-item label="手机" prop="mobile">
  44. <el-input
  45. v-model="queryParams.mobile"
  46. placeholder="请输入手机"
  47. clearable
  48. size="small"
  49. @keyup.enter.native="handleQuery"/>
  50. </el-form-item>
  51. <el-form-item label="客户状态" prop="status">
  52. <el-select v-model="queryParams.status" placeholder="请选择客户状态" clearable size="small">
  53. <el-option
  54. v-for="item in statusOptions"
  55. :key="'status'+item.dictValue"
  56. :label="item.dictLabel"
  57. :value="item.dictValue"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="客户类型" prop="customerType">
  62. <el-select multiple v-model="ctsTypeArr" placeholder="请选择客户类型" clearable size="small">
  63. <el-option
  64. v-for="item in typeOptions"
  65. :key="'type'+item.dictValue"
  66. :label="item.dictLabel"
  67. :value="item.dictValue"
  68. />
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="创建时间" prop="createTime">
  72. <el-date-picker clearable size="small" style="width: 205.4px"
  73. v-model="dateRange"
  74. type="daterange"
  75. value-format="yyyy-MM-dd"
  76. start-placeholder="开始日期" end-placeholder="结束日期">
  77. </el-date-picker>
  78. </el-form-item>
  79. <el-form-item label="领取时间" prop="receiveTimeRange">
  80. <el-date-picker
  81. style="width:205.4px"
  82. clearable size="small"
  83. v-model="receiveTimeRange"
  84. type="daterange"
  85. value-format="yyyy-MM-dd"
  86. start-placeholder="开始日期"
  87. end-placeholder="结束日期">
  88. </el-date-picker>
  89. </el-form-item>
  90. <el-form-item label="客户来源" prop="source">
  91. <el-select multiple v-model="sourceArr" placeholder="请选择客户来源" clearable size="small">
  92. <el-option
  93. v-for="item in sourceOptions"
  94. :key="'source'+item.dictValue"
  95. :label="item.dictLabel"
  96. :value="item.dictValue"
  97. />
  98. </el-select>
  99. </el-form-item>
  100. <el-form-item label="客户标签" prop="tags">
  101. <el-select multiple v-model="tagIds" placeholder="请选择客户标签" clearable size="small">
  102. <el-option
  103. v-for="item in tagsOptions"
  104. :key="'tags'+item.dictValue"
  105. :label="item.dictLabel"
  106. :value="item.dictValue"
  107. />
  108. </el-select>
  109. </el-form-item>
  110. <el-form-item label="是否下单" prop="isBuy">
  111. <el-select style="width:220px" filterable v-model="queryParams.isBuy" placeholder="请选择是否下单" clearable size="small">
  112. <el-option key="1" label="已下单" value="1" />
  113. <el-option key="0" label="未下单" value="0" />
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item>
  117. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  118. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  119. </el-form-item>
  120. </el-form>
  121. <el-row :gutter="10" class="mb8">
  122. <el-col :span="1.5">
  123. <el-button
  124. type="success"
  125. icon="el-icon-edit"
  126. size="mini"
  127. :disabled="multiple"
  128. @click="handleEditSource"
  129. v-hasPermi="['crm:customer:editSource']"
  130. >修改客户来源</el-button>
  131. </el-col>
  132. <el-col :span="1.5">
  133. <el-button
  134. type="success"
  135. icon="el-icon-edit"
  136. size="mini"
  137. :disabled="single"
  138. @click="handleUpdate"
  139. v-hasPermi="['crm:customer:edit']"
  140. >修改</el-button>
  141. </el-col>
  142. <el-col :span="1.5">
  143. <el-button
  144. type="danger"
  145. icon="el-icon-delete"
  146. size="mini"
  147. :disabled="multiple"
  148. @click="handleDelete"
  149. v-hasPermi="['crm:customer:remove']"
  150. >删除</el-button>
  151. </el-col>
  152. <el-col :span="1.5">
  153. <el-button
  154. type="warning"
  155. icon="el-icon-download"
  156. size="mini"
  157. @click="handleExport"
  158. v-hasPermi="['crm:customer:export']"
  159. >导出</el-button>
  160. </el-col>
  161. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  162. </el-row>
  163. <el-table height="500" border v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
  164. <el-table-column type="selection" width="55" align="center" />
  165. <el-table-column label="ID" align="center" prop="customerId" />
  166. <el-table-column label="所属公司" align="center" prop="companyName" />
  167. <el-table-column label="客户编码" align="center" prop="customerCode" />
  168. <el-table-column label="客户名称" align="center" prop="customerName" />
  169. <el-table-column label="手机" align="center" prop="mobile" />
  170. <el-table-column label="性别" align="center" prop="sex">
  171. <template slot-scope="scope">
  172. <el-tag prop="sex" v-for="(item, index) in sexOptions" :key="'sex'+index" v-if="scope.row.sex==item.dictValue">{{item.dictLabel}}</el-tag>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="微信号" align="center" prop="weixin" />
  176. <el-table-column label="所在地" align="center" prop="address" />
  177. <el-table-column label="标签" align="center" prop="tags" />
  178. <el-table-column label="客户来源" align="center" prop="source">
  179. <template slot-scope="scope">
  180. <el-tag prop="source" v-for="(item, index) in sourceOptions" :key="'source'+index" v-if="scope.row.source==item.dictValue">{{item.dictLabel}}</el-tag>
  181. </template>
  182. </el-table-column>
  183. <el-table-column label="客户类型" align="center" prop="customerType">
  184. <template slot-scope="scope">
  185. <el-tag prop="customerType" v-for="(item, index) in typeOptions" :key="'customerType'+index" v-if="scope.row.customerType==item.dictValue">{{item.dictLabel}}</el-tag>
  186. </template>
  187. </el-table-column>
  188. <el-table-column label="客户状态" align="center" prop="status">
  189. <template slot-scope="scope">
  190. <el-tag prop="status" v-for="(item, index) in statusOptions" :key="'status'+index" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="认领人" align="center" prop="companyUserNickName" />
  194. <el-table-column label="领取时间" align="center" prop="receiveTime" />
  195. <el-table-column label="创建时间" align="center" prop="createTime" />
  196. <el-table-column label="最后一次跟进时间" align="center" prop="lastTime" width="180">
  197. </el-table-column>
  198. <el-table-column label="入公海时间" align="center" prop="poolTime" width="180">
  199. </el-table-column>
  200. <el-table-column label="操作" fixed="right" width="180px" align="center" class-name="small-padding fixed-width">
  201. <template slot-scope="scope">
  202. <el-button
  203. size="mini"
  204. type="text"
  205. icon="el-icon-edit"
  206. @click="handleUpdate(scope.row)"
  207. v-hasPermi="['crm:customer:edit']"
  208. >修改</el-button>
  209. <el-button
  210. size="mini"
  211. type="text"
  212. @click="handleShow(scope.row)"
  213. v-hasPermi="['crm:customer:query']"
  214. >查看</el-button>
  215. <el-button
  216. size="mini"
  217. type="text"
  218. icon="el-icon-delete"
  219. @click="handleDelete(scope.row)"
  220. v-hasPermi="['crm:customer:remove']"
  221. >删除</el-button>
  222. </template>
  223. </el-table-column>
  224. </el-table>
  225. <pagination
  226. v-show="total>0"
  227. :total="total"
  228. :page-sizes="pageSizes"
  229. :page.sync="queryParams.pageNum"
  230. :limit.sync="queryParams.pageSize"
  231. @pagination="getList"
  232. />
  233. <!-- 添加或修改客户对话框 -->
  234. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  235. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  236. <el-form-item label="客户编码" prop="customerCode">
  237. <el-input v-model="form.customerCode" :disabled="form.customerId!=null" placeholder="请输入客户编码" />
  238. </el-form-item>
  239. <el-form-item label="客户名称" prop="customerName">
  240. <el-input v-model="form.customerName" placeholder="请输入客户名称" />
  241. </el-form-item>
  242. <el-form-item label="手机" prop="mobile">
  243. <el-input maxlength="11" v-model="form.mobile" placeholder="请输入手机" />
  244. </el-form-item>
  245. <el-form-item label="性别" prop="sex">
  246. <el-radio-group v-model="form.sex">
  247. <el-radio :label="item.dictValue" v-for="item in sexOptions" >{{item.dictLabel}}</el-radio>
  248. </el-radio-group>
  249. </el-form-item>
  250. <el-form-item label="微信号" prop="weixin">
  251. <el-input v-model="form.weixin" placeholder="请输入性别" />
  252. </el-form-item>
  253. <el-form-item label="所在地区" prop="address">
  254. <el-cascader
  255. ref="citySelect"
  256. v-model="cityIds"
  257. :options="citys"
  258. @change="handleCityChange"></el-cascader>
  259. </el-form-item>
  260. <el-form-item label="详细地址" prop="detailAddress">
  261. <el-input v-model="form.detailAddress" placeholder="请输入详细地址" />
  262. </el-form-item>
  263. <el-form-item label="客户来源" prop="source">
  264. <el-select v-model="form.source" placeholder="请选择客户来源" clearable size="small">
  265. <el-option
  266. v-for="item in sourceOptions"
  267. :key="item.dictValue"
  268. :label="item.dictLabel"
  269. :value="item.dictValue"
  270. />
  271. </el-select>
  272. </el-form-item>
  273. <el-form-item label="客户类型" prop="customerType">
  274. <el-select v-model="form.customerType" placeholder="请选择客户类型" clearable size="small">
  275. <el-option
  276. v-for="item in typeOptions"
  277. :key="item.dictValue"
  278. :label="item.dictLabel"
  279. :value="item.dictValue"
  280. />
  281. </el-select>
  282. </el-form-item>
  283. <el-form-item label="客户状态">
  284. <el-radio-group v-model="form.status">
  285. <el-radio :label="item.dictValue" v-for="item in statusOptions">{{item.dictLabel}}</el-radio>
  286. </el-radio-group>
  287. </el-form-item>
  288. <el-form-item label="标签" prop="tags">
  289. <el-tag
  290. :key="tag"
  291. v-for="tag in tags"
  292. closable
  293. :disable-transitions="false"
  294. @close="handleClose(tag)">
  295. {{tag}}
  296. </el-tag>
  297. <el-input
  298. class="input-new-tag"
  299. v-if="inputVisible"
  300. v-model="inputValue"
  301. ref="saveTagInput"
  302. size="small"
  303. @keyup.enter.native="handleInputConfirm"
  304. @blur="handleInputConfirm"
  305. >
  306. </el-input>
  307. <el-button v-else class="button-new-tag" size="small" @click="showInput">添加标签+</el-button>
  308. <el-select @change="tagsChange" v-model="tagId" placeholder="选择客户来源" style="width:140px;margin-left: 5px;" clearable size="small">
  309. <el-option
  310. v-for="item in tagsOptions"
  311. :key="item.dictValue"
  312. :label="item.dictLabel"
  313. :value="item.dictValue"
  314. />
  315. </el-select>
  316. </el-form-item>
  317. <el-form-item label="备注" prop="remark">
  318. <el-input :rows="2" v-model="form.remark" type="textarea" placeholder="请输入内容" />
  319. </el-form-item>
  320. </el-form>
  321. <div slot="footer" class="dialog-footer">
  322. <el-button type="primary" @click="submitForm">确 定</el-button>
  323. <el-button @click="cancel">取 消</el-button>
  324. </div>
  325. </el-dialog>
  326. <el-drawer
  327. size="75%"
  328. :title="show.title" :visible.sync="show.open">
  329. <customer-details ref="customerDetails" />
  330. </el-drawer>
  331. <el-dialog :title="source.title" :visible.sync="source.open" width="600px" append-to-body>
  332. <edit-customer-source ref="editSource" @close="closeSource"></edit-customer-source>
  333. </el-dialog>
  334. </div>
  335. </template>
  336. <script>
  337. import { listCustomer,getCustomer,addCustomer,updateCustomer,delCustomer,exportCustomer } from "@/api/crm/customer";
  338. import { getCompanyList } from "@/api/company/company";
  339. import customerDetails from '../components/customerDetails.vue';
  340. import editCustomerSource from '../components/editCustomerSource.vue';
  341. import {getCitys} from "@/api/store/city";
  342. import { throwStatement } from "@babel/types";
  343. import { treeselect } from "@/api/company/companyDept";
  344. import Treeselect from "@riophae/vue-treeselect";
  345. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  346. export default {
  347. watch: {
  348. // 监听deptId
  349. 'deptId': 'currDeptChange'
  350. },
  351. name: "Customer",
  352. components: { customerDetails,editCustomerSource,Treeselect },
  353. data() {
  354. return {
  355. source:{
  356. title:"修改客户来源",
  357. open:false,
  358. },
  359. deptOptions:[],
  360. receiveTimeRange:[],
  361. tagId:null,
  362. deptId:undefined,
  363. companyId:undefined,
  364. tagsOptions:[],
  365. ctsTypeArr:[],
  366. sourceArr:[],
  367. dateRange:[],
  368. cityIds:[],
  369. citys:[],
  370. tags:[],
  371. tagIds:[],
  372. inputVisible: false,
  373. inputValue: '',
  374. statusOptions:[],
  375. typeOptions:[],
  376. sourceOptions:[],
  377. sexOptions:[],
  378. pageSizes: [10, 20, 30, 50,100,500 ],
  379. show:{
  380. title:"客户详情",
  381. open:false,
  382. },
  383. companys:[],
  384. // 遮罩层
  385. loading: true,
  386. // 选中数组
  387. ids: [],
  388. // 非单个禁用
  389. single: true,
  390. // 非多个禁用
  391. multiple: true,
  392. // 显示搜索条件
  393. showSearch: true,
  394. // 总条数
  395. total: 0,
  396. // 客户表格数据
  397. customerList: [],
  398. // 弹出层标题
  399. title: "",
  400. // 是否显示弹出层
  401. open: false,
  402. // 查询参数
  403. queryParams: {
  404. pageNum: 1,
  405. pageSize: 10,
  406. customerCode: null,
  407. customerName: null,
  408. mobile: null,
  409. sex: null,
  410. weixin: null,
  411. userId: null,
  412. createUserId: null,
  413. receiveUserId: null,
  414. customerUserId: null,
  415. address: null,
  416. location: null,
  417. detailAddress: null,
  418. lng: null,
  419. lat: null,
  420. status: null,
  421. isReceive: null,
  422. deptId: null,
  423. isDel: null,
  424. customerType: null,
  425. receiveTime: null,
  426. poolTime: null,
  427. companyId: null,
  428. isLine: null,
  429. source: null,
  430. tags: null
  431. },
  432. // 表单参数
  433. form: {},
  434. // 表单校验
  435. rules: {
  436. // customerName: [
  437. // { required: true, message: "客户名称不能为空", trigger: "blur" }
  438. // ],
  439. mobile: [
  440. { required: true, message: "手机号不能为空", trigger: "blur" }
  441. ],
  442. // sex: [
  443. // { required: true, message: "性别不能为空", trigger: "blur" }
  444. // ],
  445. source: [
  446. { required: true, message: "客户来源不能为空", trigger: "blur" }
  447. ],
  448. }
  449. };
  450. },
  451. created() {
  452. this.getDicts("crm_customer_tag").then((response) => {
  453. this.tagsOptions = response.data;
  454. });
  455. this.getDicts("crm_customer_source").then((response) => {
  456. this.sourceOptions = response.data;
  457. });
  458. this.getDicts("common_sex").then((response) => {
  459. this.sexOptions = response.data;
  460. });
  461. this.getDicts("crm_customer_status").then((response) => {
  462. this.statusOptions = response.data;
  463. });
  464. this.getDicts("crm_customer_type").then((response) => {
  465. this.typeOptions = response.data;
  466. });
  467. getCompanyList().then(response => {
  468. this.companys = response.data;
  469. });
  470. this.getCitys();
  471. this.getList();
  472. },
  473. methods: {
  474. handleEditSource(){
  475. this.source.open=true;
  476. var that=this;
  477. setTimeout(() => {
  478. that.$refs.editSource.handleEdit(that.ids);
  479. }, 200);
  480. },
  481. closeSource(){
  482. this.source.open=false;
  483. this.getList();
  484. },
  485. handleClose(tag) {
  486. this.tags.splice(this.tags.indexOf(tag), 1);
  487. this.form.tags=this.tags.toString();
  488. },
  489. showInput() {
  490. this.inputVisible = true;
  491. this.$nextTick(_ => {
  492. this.$refs.saveTagInput.$refs.input.focus();
  493. });
  494. },
  495. handleInputConfirm() {
  496. let inputValue = this.inputValue;
  497. if (inputValue) {
  498. this.tags.push(inputValue);
  499. }
  500. this.inputVisible = false;
  501. this.inputValue = '';
  502. this.form.tags=this.tags.toString();
  503. },
  504. tagsChange(e){
  505. var item=this.tagsOptions.find(val => val.dictValue === e);
  506. console.log(item);
  507. this.tags.push(item.dictLabel);
  508. this.form.tags=this.tags.toString();
  509. },
  510. handleCityChange(value) {
  511. console.log(value);
  512. var nodes=this.$refs.citySelect.getCheckedNodes();
  513. this.form.address=nodes[0].pathLabels[0]+"-"+nodes[0].pathLabels[1]+"-"+nodes[0].pathLabels[2];
  514. this.form.cityIds=value.toString();
  515. },
  516. getCitys(){
  517. getCitys().then(res => {
  518. this.loading = false;
  519. this.citys=res.data;
  520. })
  521. },
  522. handleClose(tag) {
  523. this.tags.splice(this.tags.indexOf(tag), 1);
  524. this.form.tags=this.tags.toString();
  525. },
  526. showInput() {
  527. this.inputVisible = true;
  528. this.$nextTick(_ => {
  529. this.$refs.saveTagInput.$refs.input.focus();
  530. });
  531. },
  532. handleInputConfirm() {
  533. let inputValue = this.inputValue;
  534. if (inputValue) {
  535. this.tags.push(inputValue);
  536. }
  537. this.inputVisible = false;
  538. this.inputValue = '';
  539. this.form.tags=this.tags.toString();
  540. },
  541. handleShow(row){
  542. var that=this;
  543. that.show.open=true;
  544. setTimeout(() => {
  545. that.$refs.customerDetails.getDetails(row.customerId);
  546. }, 200);
  547. },
  548. /** 查询客户列表 */
  549. getList() {
  550. this.loading = true;
  551. if(this.receiveTimeRange!=null&&this.receiveTimeRange.length==2){
  552. this.queryParams.receiveTimeRange=this.receiveTimeRange[0]+"--"+this.receiveTimeRange[1]
  553. }
  554. else{
  555. this.queryParams.receiveTimeRange=null;
  556. }
  557. if(this.ctsTypeArr.length>0){
  558. this.queryParams.customerType=this.ctsTypeArr.toString();
  559. }
  560. else{
  561. this.queryParams.customerType=null
  562. }
  563. if(this.sourceArr.length>0){
  564. this.queryParams.source=this.sourceArr.toString();
  565. }
  566. else{
  567. this.queryParams.source=null
  568. }
  569. if(this.tagIds.length>0){
  570. this.queryParams.tags=this.tagIds.toString();
  571. }
  572. else{
  573. this.queryParams.tags=null
  574. }
  575. listCustomer(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  576. this.customerList = response.rows;
  577. this.total = response.total;
  578. this.loading = false;
  579. });
  580. },
  581. // 取消按钮
  582. cancel() {
  583. this.open = false;
  584. this.reset();
  585. },
  586. // 表单重置
  587. reset() {
  588. this.form = {
  589. customerId: null,
  590. customerCode: null,
  591. customerName: null,
  592. mobile: null,
  593. sex: null,
  594. weixin: null,
  595. remark: null,
  596. userId: null,
  597. createUserId: null,
  598. receiveUserId: null,
  599. customerUserId: null,
  600. address: null,
  601. location: null,
  602. detailAddress: null,
  603. lng: null,
  604. lat: null,
  605. createTime: null,
  606. updateTime: null,
  607. status: "1",
  608. isReceive: null,
  609. deptId: null,
  610. isDel: null,
  611. customerType: null,
  612. receiveTime: null,
  613. poolTime: null,
  614. companyId: null,
  615. isLine: null,
  616. source: null,
  617. tags: null
  618. };
  619. this.tags=[];
  620. this.cityIds=[];
  621. this.resetForm("form");
  622. },
  623. /** 搜索按钮操作 */
  624. handleQuery() {
  625. this.queryParams.pageNum = 1;
  626. this.getList();
  627. },
  628. /** 重置按钮操作 */
  629. resetQuery() {
  630. this.resetForm("queryForm");
  631. this.handleQuery();
  632. },
  633. // 多选框选中数据
  634. handleSelectionChange(selection) {
  635. this.ids = selection.map(item => item.customerId)
  636. this.single = selection.length!==1
  637. this.multiple = !selection.length
  638. },
  639. /** 新增按钮操作 */
  640. handleAdd() {
  641. this.reset();
  642. this.open = true;
  643. this.title = "添加客户";
  644. },
  645. /** 修改按钮操作 */
  646. handleUpdate(row) {
  647. this.reset();
  648. const customerId = row.customerId || this.ids
  649. var that=this;
  650. getCustomer(customerId).then(response => {
  651. this.form = response.customer;
  652. if(this.form.status!=null){
  653. this.form.status = this.form.status.toString();
  654. }
  655. if(this.form.customerType!=null){
  656. this.form.customerType = this.form.customerType.toString();
  657. }
  658. if(this.form.sex!=null){
  659. this.form.sex = this.form.sex.toString();
  660. }
  661. if(this.form.source!=null){
  662. this.form.source = this.form.source.toString();
  663. }
  664. if(this.form.tags!=null){
  665. this.tags = this.form.tags.split(",")
  666. }
  667. if(this.form.cityIds!=null){
  668. var ids=this.form.cityIds.split(",");
  669. this.cityIds=[];
  670. ids.forEach(element => {
  671. var id=parseInt(element);
  672. that.cityIds.push(id)
  673. });
  674. }
  675. this.open = true;
  676. this.title = "修改客户";
  677. });
  678. },
  679. /** 提交按钮 */
  680. submitForm() {
  681. this.$refs["form"].validate(valid => {
  682. if (valid) {
  683. if (this.form.customerId != null) {
  684. updateCustomer(this.form).then(response => {
  685. if (response.code === 200) {
  686. this.msgSuccess("修改成功");
  687. this.open = false;
  688. this.getList();
  689. }
  690. });
  691. } else {
  692. addCustomer(this.form).then(response => {
  693. if (response.code === 200) {
  694. this.msgSuccess("新增成功");
  695. this.open = false;
  696. this.getList();
  697. }
  698. });
  699. }
  700. }
  701. });
  702. },
  703. /** 删除按钮操作 */
  704. handleDelete(row) {
  705. const customerIds = row.customerId || this.ids;
  706. this.$confirm('是否确认删除客户编号为"' + customerIds + '"的数据项?', "警告", {
  707. confirmButtonText: "确定",
  708. cancelButtonText: "取消",
  709. type: "warning"
  710. }).then(function() {
  711. return delCustomer(customerIds);
  712. }).then(() => {
  713. this.getList();
  714. this.msgSuccess("删除成功");
  715. }).catch(function() {});
  716. },
  717. /** 导出按钮操作 */
  718. handleExport() {
  719. //const queryParams = this.queryParams;
  720. const queryParams=this.addDateRange(this.queryParams, this.dateRange)
  721. this.$confirm('是否确认导出客户数据项?', "警告", {
  722. confirmButtonText: "确定",
  723. cancelButtonText: "取消",
  724. type: "warning"
  725. }).then(function() {
  726. return exportCustomer(queryParams);
  727. }).then(response => {
  728. this.download(response.msg);
  729. }).catch(function() {});
  730. },
  731. getTreeselect() {
  732. var that=this;
  733. var param={companyId:this.companyId}
  734. treeselect(param).then((response) => {
  735. this.deptOptions = response.data;
  736. console.log(this.deptOptions)
  737. if(response.data!=null&&response.data.length>0){
  738. //this.queryParams.deptId=response.data[0].id;
  739. }
  740. });
  741. },
  742. companyChange(val){
  743. console.log(val);
  744. this.companyId=val;
  745. this.getTreeselect();
  746. },
  747. currDeptChange(val){
  748. console.log(val)
  749. this.queryParams.deptId=val;
  750. this.getList();
  751. },
  752. }
  753. };
  754. </script>
  755. <style>
  756. .el-tag + .el-tag {
  757. margin-left: 10px;
  758. }
  759. .button-new-tag {
  760. margin-left: 10px;
  761. height: 32px;
  762. line-height: 30px;
  763. padding-top: 0;
  764. padding-bottom: 0;
  765. }
  766. .input-new-tag {
  767. width: 90px;
  768. margin-left: 10px;
  769. vertical-align: bottom;
  770. }
  771. .el-dialog__wrapper{
  772. z-index: 100000;
  773. }
  774. </style>