index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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="customer">
  5. <el-input
  6. v-model="queryParams.customer"
  7. placeholder="请输入客户姓名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="干系人" prop="stakeholder">
  14. <el-input
  15. v-model="queryParams.stakeholder"
  16. placeholder="请输入干系人姓名"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="是否启用" prop="enable">
  23. <el-select v-model="queryParams.enable" placeholder="是否启用" clearable size="small" style="width: 240px">
  24. <el-option v-for="dict in enableOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. icon="el-icon-plus"
  37. size="mini"
  38. @click="handleAdd"
  39. v-hasPermi="['system:personal:page:add']"
  40. >新增</el-button>
  41. </el-col>
  42. <!-- <el-col :span="1.5">
  43. <el-button
  44. type="success"
  45. icon="el-icon-edit"
  46. size="mini"
  47. :disabled="single"
  48. @click="handleUpdate"
  49. v-hasPermi="['system:personal:page:edit']"
  50. >修改</el-button>
  51. </el-col> -->
  52. <el-col :span="1.5">
  53. <el-button
  54. type="danger"
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. v-hasPermi="['system:personal:page:remove']"
  60. >删除</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <el-table v-loading="loading" :data="pageList" @selection-change="handleSelectionChange">
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column label="姓名" align="center" prop="customer" width="280" />
  67. <el-table-column label="干系人姓名" align="center" prop="stakeholder" width="280" />
  68. <el-table-column label="启用" align="center" width="180">
  69. <template slot-scope="scope">
  70. <el-switch v-model="scope.row.enable" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  71. </template>
  72. </el-table-column>
  73. <!-- <el-table-column label="备注" align="center" prop="remarks" /> -->
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-chat-line-square"
  80. @click="preview(scope.row)"
  81. v-hasPermi="['system:personal:message:query']"
  82. >预览</el-button>
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-edit"
  87. @click="handleUpdate(scope.row)"
  88. v-hasPermi="['system:personal:page:edit']"
  89. >修改</el-button>
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-chat-line-square"
  94. @click="handleMessage(scope.row)"
  95. v-hasPermi="['system:personal:message:list']"
  96. >留言</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination
  101. v-show="total>0"
  102. :total="total"
  103. :page.sync="queryParams.pageNum"
  104. :limit.sync="queryParams.pageSize"
  105. @pagination="getList"
  106. />
  107. <!-- 添加或修改个人页对话框 -->
  108. <el-dialog :title="title" v-if="open" :visible.sync="open" width="1000px" append-to-body :close-on-click-modal=false>
  109. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  110. <el-row :gutter="0" type="flex" justify="start">
  111. <el-col :span="8">
  112. <el-form-item label="客户姓名" prop="customerId">
  113. <el-select
  114. v-model="form.customer"
  115. filterable
  116. remote
  117. clearable
  118. placeholder="请输入名字/手机号查询"
  119. :remote-method="findCustomer"
  120. @change="customerChange"
  121. :loading="loadings">
  122. <el-option
  123. v-for="item in customerOptions"
  124. :key="item.userId"
  125. :label="item.nickName"
  126. :value="item.userId">
  127. </el-option>
  128. </el-select>
  129. </el-form-item>
  130. <el-form-item label="干系人" prop="stakeholderId">
  131. <el-select
  132. v-model="form.stakeholder"
  133. filterable
  134. remote
  135. clearable
  136. placeholder="请输入名字/手机号查询"
  137. :remote-method="findStakeholder"
  138. @change="stakeholderChange"
  139. :loading="loadings">
  140. <el-option
  141. v-for="item in stakeholderOptions"
  142. :key="item.userId"
  143. :label="item.nickName"
  144. :value="item.userId">
  145. </el-option>
  146. </el-select>
  147. </el-form-item>
  148. <!-- <el-form-item label="干系人姓名" prop="stakeholder">
  149. <el-input v-model="form.stakeholder" placeholder="请输入干系人姓名" />
  150. </el-form-item> -->
  151. </el-col>
  152. <el-col :span="8">
  153. <el-form-item label="二维码" prop="qrcode">
  154. <el-image
  155. style="width: 36px; height: 36px"
  156. :src="codeImg"
  157. :preview-src-list="[codeUrl]">
  158. </el-image>
  159. </el-form-item>
  160. <el-form-item label="启用" prop="enable">
  161. <el-radio-group v-model="form.enable">
  162. <el-radio
  163. v-for="dict in enableOptions"
  164. :key="dict.dictValue"
  165. :label="dict.dictValue"
  166. >{{dict.dictLabel}}</el-radio>
  167. </el-radio-group>
  168. </el-form-item>
  169. </el-col>
  170. </el-row>
  171. <el-form-item label="个人生平" prop="content">
  172. <editor v-model="form.content" :min-height="492" :params="editParams" ref="myEditor"/>
  173. </el-form-item>
  174. </el-form>
  175. <div slot="footer" class="dialog-footer">
  176. <el-button type="primary" @click="submitForm">确 定</el-button>
  177. <el-button @click="cancel">取 消</el-button>
  178. </div>
  179. </el-dialog>
  180. </div>
  181. </template>
  182. <script>
  183. import { listPersonal, getPersonal, delPersonal, addPersonal, updatePersonal, exportPersonal,changeEnable,getQrcode } from "@/api/system/personalPage";
  184. import { listUser } from "@/api/system/appUser";
  185. import Editor from '@/components/Editor';
  186. import qrcodeImg from '@/assets/image/qrcode_img.jpg'
  187. export default {
  188. name: "personalPage",
  189. components: {
  190. Editor,
  191. },
  192. data() {
  193. return {
  194. codeImg: qrcodeImg,
  195. codeUrl: "",
  196. // 遮罩层
  197. loading: true,
  198. loadings: false,
  199. // 选中数组
  200. ids: [],
  201. // 非单个禁用
  202. single: true,
  203. // 非多个禁用
  204. multiple: true,
  205. // 显示搜索条件
  206. showSearch: true,
  207. // 总条数
  208. total: 0,
  209. // 个人页表格数据
  210. pageList: [],
  211. // 弹出层标题
  212. title: "",
  213. // 是否显示弹出层
  214. open: false,
  215. // 是否启用数据字典
  216. enableOptions: [],
  217. customerOptions:[],
  218. stakeholderOptions:[],
  219. // 查询参数
  220. customerParams: {
  221. enable: 0,
  222. searchValue: null,
  223. },
  224. // 查询参数
  225. queryParams: {
  226. pageNum: 1,
  227. pageSize: 10,
  228. customer: null,
  229. stakeholder: null,
  230. stakeholderBirthday: null,
  231. enable: null,
  232. modifyBy: null,
  233. modifyTime: null,
  234. remarks: null
  235. },
  236. // 表单参数
  237. form: {},
  238. // 表单校验
  239. rules: {
  240. customerId: [
  241. { required: true, message: "客户不能为空", trigger: "blur" },
  242. ],
  243. stakeholderId: [
  244. { required: true, message: "干系人不能为空", trigger: "blur" },
  245. ],
  246. },
  247. reFresh: 1,
  248. templateParam:{
  249. enable: 0
  250. },
  251. // 固定个人模板页
  252. templateRoute: "/template/t",
  253. templateList: [],
  254. editParams: {
  255. modName: '/personal/'
  256. }
  257. };
  258. },
  259. watch:{
  260. // 监听form值,只要有改变,则key值reFresh变更。
  261. // 然后自定义上传图片组件personalAvatar重新渲染
  262. form(){
  263. ++this.reFresh
  264. }
  265. },
  266. created() {
  267. this.getList();
  268. this.getDicts("sys_normal_disable").then((response) => {
  269. this.enableOptions = response.data;
  270. });
  271. },
  272. methods: {
  273. findCustomer(query){
  274. if (query.length > 1) {
  275. this.loadings = true;
  276. this.customerParams.searchValue = query;
  277. listUser(this.customerParams).then(response => {
  278. this.loadings = false;
  279. this.customerOptions = response.data;
  280. });
  281. }
  282. },
  283. findStakeholder(query){
  284. if (query.length > 1) {
  285. this.loadings = true;
  286. this.customerParams.searchValue = query;
  287. listUser(this.customerParams).then(response => {
  288. this.loadings = false;
  289. this.stakeholderOptions = response.data;
  290. });
  291. }
  292. },
  293. customerChange(value){
  294. this.form.customerId = value;
  295. let obj = {};
  296. obj = this.customerOptions.find((item)=>{
  297. return item.userId === value;
  298. });
  299. this.form.customer = obj.nickName
  300. },
  301. stakeholderChange(value){
  302. this.form.stakeholderId = value;
  303. let obj = {};
  304. obj = this.stakeholderOptions.find((item)=>{
  305. return item.userId === value;
  306. });
  307. this.form.stakeholder = obj.nickName
  308. },
  309. /** 查询个人页列表 */
  310. getList() {
  311. this.loading = true;
  312. listPersonal(this.queryParams).then(response => {
  313. this.pageList = response.rows;
  314. this.total = response.total;
  315. this.loading = false;
  316. });
  317. },
  318. getTemplateList(){
  319. listTemplate(this.templateParam).then(response => {
  320. this.templateList = response.rows;
  321. });
  322. },
  323. // 取消按钮
  324. cancel() {
  325. this.open = false;
  326. this.reset();
  327. },
  328. // 表单重置
  329. reset() {
  330. this.form = {
  331. id: null,
  332. customer: null,
  333. avatar : null,
  334. stakeholder: null,
  335. stakeholderBirthday: null,
  336. enable: null,
  337. createBy: null,
  338. createTime: null,
  339. modifyBy: null,
  340. modifyTime: null,
  341. remarks: null,
  342. customerOptions: null
  343. };
  344. this.resetForm("form");
  345. },
  346. /** 搜索按钮操作 */
  347. handleQuery() {
  348. this.queryParams.pageNum = 1;
  349. this.getList();
  350. },
  351. /** 重置按钮操作 */
  352. resetQuery() {
  353. this.resetForm("queryForm");
  354. this.handleQuery();
  355. },
  356. // 多选框选中数据
  357. handleSelectionChange(selection) {
  358. this.ids = selection.map(item => item.id)
  359. this.single = selection.length!==1
  360. this.multiple = !selection.length
  361. },
  362. // 用户状态修改
  363. handleStatusChange(row) {
  364. let text = row.enable === "0" ? "启用" : "停用";
  365. this.$confirm(
  366. '确认要 ' + text + ' 吗?',
  367. "警告",
  368. {
  369. confirmButtonText: "确定",
  370. cancelButtonText: "取消",
  371. type: "warning",
  372. }
  373. )
  374. .then(function () {
  375. return changeEnable(row.id, row.enable);
  376. })
  377. .then(() => {
  378. this.msgSuccess(text + "成功");
  379. })
  380. .catch(function () {
  381. row.enable = row.enable === "0" ? "1" : "0";
  382. });
  383. },
  384. /** 新增按钮操作 */
  385. handleAdd() {
  386. this.reset();
  387. this.open = true;
  388. this.title = "添加个人页";
  389. this.codeUrl = "";
  390. },
  391. /** 修改按钮操作 */
  392. handleUpdate(row) {
  393. this.reset();
  394. const id = row.id || this.ids
  395. getPersonal(id).then(response => {
  396. this.form = response.data;
  397. this.getQrcodeImg(row);
  398. this.open = true;
  399. this.title = "修改个人页";
  400. });
  401. },
  402. /** 提交按钮 */
  403. submitForm() {
  404. this.$refs["form"].validate(valid => {
  405. if (valid) {
  406. if (this.form.id != null) {
  407. updatePersonal(this.form).then(response => {
  408. if (response.code === 200) {
  409. this.msgSuccess("修改成功");
  410. this.open = false;
  411. this.getList();
  412. }
  413. });
  414. } else {
  415. addPersonal(this.form).then(response => {
  416. if (response.code === 200) {
  417. this.msgSuccess("新增成功");
  418. this.open = false;
  419. this.getList();
  420. }
  421. });
  422. }
  423. }
  424. });
  425. },
  426. /** 删除按钮操作 */
  427. handleDelete(row) {
  428. const ids = row.id || this.ids;
  429. this.$confirm('是否确认删除个人页编号为"' + ids + '"的数据项?', "警告", {
  430. confirmButtonText: "确定",
  431. cancelButtonText: "取消",
  432. type: "warning"
  433. }).then(function() {
  434. return delPersonal(ids);
  435. }).then(() => {
  436. this.getList();
  437. this.msgSuccess("删除成功");
  438. }).catch(function() {});
  439. },
  440. /** 导出按钮操作 */
  441. handleExport() {
  442. const queryParams = this.queryParams;
  443. this.$confirm('是否确认导出所有个人页数据项?', "警告", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "warning"
  447. }).then(function() {
  448. return exportPersonal(queryParams);
  449. }).then(response => {
  450. this.download(response.msg);
  451. }).catch(function() {});
  452. },
  453. getQrcodeImg(row) {
  454. const pid = row.id;
  455. const tid = row.templateId;
  456. // const route = this.templateList.find(item => item.id === tid).route;
  457. const url = window.location.origin + this.templateRoute+'/' + pid
  458. const param = {url:url}
  459. getQrcode(param).then(res => {
  460. this.codeUrl = "data:image/gif;base64," + res.img;
  461. });
  462. },
  463. viewPage(){
  464. debugger
  465. const pid = this.form.id;
  466. const tid = this.form.templateId;
  467. // const route = this.templateList.find(item => item.id === tid).route;
  468. console.log(window.location.origin + this.templateRoute+'/' + pid)
  469. var win = window.open(window.location.origin + this.templateRoute+'/' + pid);
  470. win.document.title='个人页 - '+this.form.stakeholder
  471. },
  472. preview(row) {
  473. const pid = row.id;
  474. const tid = row.templateId;
  475. // const route = this.templateList.find(item => item.id === tid).route;
  476. var win = window.open(window.location.origin + this.templateRoute+'/' + pid);
  477. },
  478. handleMessage(row) {
  479. this.$router.push({
  480. path: "/personal/message",
  481. query: {
  482. mid: row.id
  483. }
  484. });
  485. },
  486. img(row) {
  487. this.$router.push({
  488. path: "/personal/pic",
  489. query: {
  490. pid: row.id
  491. }
  492. });
  493. },
  494. video(row) {
  495. this.$router.push({
  496. path: "/personal/video",
  497. query: {
  498. pid: row.id
  499. }
  500. });
  501. },
  502. }
  503. };
  504. </script>
  505. <style>
  506. /* .el-dialog__body {
  507. padding: 10px 20px;
  508. } */
  509. /* .el-form-item {
  510. margin-bottom: 8px;
  511. } */
  512. </style>