index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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="title">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入名片标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery" />
  11. </el-form-item>
  12. <el-form-item label="名片类型" prop="type">
  13. <el-select filterable v-model="queryParams.type" placeholder="请选择类型" clearable size="small">
  14. <el-option
  15. v-for="item in typeOptions"
  16. :key="item.dictValue"
  17. :label="item.dictLabel"
  18. :value="item.dictValue"
  19. />
  20. </el-select>
  21. </el-form-item>
  22. <!-- <el-form-item label="名片访问次数" prop="lookNum">
  23. <el-input
  24. v-model="queryParams.lookNum"
  25. placeholder="请输入名片访问次数"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="名片访问人数" prop="personNum">
  32. <el-input
  33. v-model="queryParams.personNum"
  34. placeholder="请输入名片访问人数"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item> -->
  40. <el-form-item>
  41. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <el-col :span="1.5">
  47. <el-button
  48. type="primary"
  49. icon="el-icon-plus"
  50. size="mini"
  51. @click="handleAdd"
  52. v-hasPermi="['company:companUsercard:add']"
  53. >新增</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="success"
  58. icon="el-icon-edit"
  59. size="mini"
  60. :disabled="single"
  61. @click="handleUpdate"
  62. v-hasPermi="['company:companUsercard:edit']"
  63. >修改</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="danger"
  68. icon="el-icon-delete"
  69. size="mini"
  70. :disabled="multiple"
  71. @click="handleDelete"
  72. v-hasPermi="['company:companUsercard:remove']"
  73. >删除</el-button>
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-button
  77. type="warning"
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport"
  81. v-hasPermi="['company:companUsercard:export']"
  82. >导出</el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="cardList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="55" align="center" />
  88. <el-table-column width="55" label="Id" align="center" prop="id" />
  89. <el-table-column width="60" label="用户ID" align="center" prop="userId" />
  90. <el-table-column label="名片标题" align="center" prop="title" />
  91. <el-table-column label="名片图片" align="center" width="120">
  92. <template slot-scope="scope">
  93. <el-popover
  94. placement="right"
  95. title=""
  96. trigger="hover">
  97. <img slot="reference" :src="scope.row.imageUrl" width="100">
  98. <img :src="scope.row.imageUrl" style="max-width: 150px;">
  99. </el-popover>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="名片短链接" width="100" align="center" prop="shortUrl" />
  103. <el-table-column label="创建时间" width="100" align="center" prop="createTime" />
  104. <el-table-column label="名片类型" align="center" prop="type">
  105. <template slot-scope="scope">
  106. <el-tag prop="type" v-for="(item, index) in typeOptions" v-if="scope.row.type==item.dictValue">{{item.dictLabel}}</el-tag>
  107. </template>
  108. </el-table-column>
  109. <!-- <el-table-column label="是否访问" align="center" prop="isVisit" /> -->
  110. <el-table-column label="访问次数" width="110" align="center" prop="lookNum" />
  111. <!-- <el-table-column label="名片访问人数" align="center" prop="personNum" />
  112. <el-table-column label="名片访问ip数" align="center" prop="ipNum" /> -->
  113. <el-table-column label="操作" width="200" align="center" class-name="small-padding fixed-width">
  114. <template slot-scope="scope">
  115. <el-button
  116. size="mini"
  117. type="text"
  118. icon="el-icon-sms"
  119. @click="handleSms(scope.row)"
  120. >发短信</el-button>
  121. <el-button
  122. size="mini"
  123. type="text"
  124. icon="el-icon-edit"
  125. @click="handleUpdate(scope.row)"
  126. v-hasPermi="['company:companUsercard:edit']"
  127. >修改</el-button>
  128. <el-button
  129. size="mini"
  130. type="text"
  131. icon="el-icon-delete"
  132. @click="handleDelete(scope.row)"
  133. v-hasPermi="['company:companUsercard:remove']"
  134. >删除</el-button>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. <pagination
  139. v-show="total>0"
  140. :total="total"
  141. :page.sync="queryParams.pageNum"
  142. :limit.sync="queryParams.pageSize"
  143. @pagination="getList"
  144. />
  145. <!-- 添加或修改card对话框 -->
  146. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  147. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  148. <el-form-item label="名片标题" prop="title">
  149. <el-input v-model="form.title" placeholder="请输入名片标题" />
  150. </el-form-item>
  151. <el-form-item label="名片类型" prop="type">
  152. <el-select style="width: 200px" v-model="form.type" placeholder="请选择类型" clearable size="small" >
  153. <el-option
  154. v-for="item in typeOptions"
  155. :key="item.dictValue"
  156. :label="item.dictLabel"
  157. :value="item.dictValue"
  158. />
  159. </el-select>
  160. </el-form-item>
  161. <el-form-item label="名片图片" prop="imageUrl">
  162. <el-upload
  163. v-model="form.icon"
  164. class="avatar-uploader"
  165. :action="uploadUrl"
  166. :show-file-list="false"
  167. :on-success="handleAvatarSuccess"
  168. :before-upload="beforeAvatarUpload">
  169. <img v-if="form.imageUrl" :src="form.imageUrl" class="avatar">
  170. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  171. </el-upload>
  172. </el-form-item>
  173. <!-- <el-form-item label="微信名片短链接" prop="shortUrl">
  174. <el-input v-model="form.shortUrl" placeholder="请输入微信名片短链接" />
  175. </el-form-item>
  176. <el-form-item label="是否访问" prop="isVisit">
  177. <el-input v-model="form.isVisit" placeholder="请输入微信名片短链接" />
  178. </el-form-item> -->
  179. <el-form-item label="名片访问次数" prop="lookNum">
  180. <el-input v-model="form.lookNum" style="width:200px" placeholder="请输入名片访问次数" />
  181. </el-form-item>
  182. <!-- <el-form-item label="名片访问人数" prop="personNum">
  183. <el-input v-model="form.personNum" placeholder="请输入名片访问人数" />
  184. </el-form-item>
  185. <el-form-item label="名片访问ip数" prop="ipNum">
  186. <el-input v-model="form.ipNum" placeholder="请输入名片访问ip数" />
  187. </el-form-item> -->
  188. </el-form>
  189. <div slot="footer" class="dialog-footer">
  190. <el-button type="primary" @click="submitForm">确 定</el-button>
  191. <el-button @click="cancel">取 消</el-button>
  192. </div>
  193. </el-dialog>
  194. <el-dialog :title="addSms.title" :visible.sync="addSms.open" width="800px" append-to-body>
  195. <add-sms ref="sms" @close="closeSms()" @handleAddCustomer="handleAddCustomer()" ></add-sms>
  196. </el-dialog>
  197. <el-dialog :title="customer.title" v-if="customer.open" :visible.sync="customer.open" width="900px" append-to-body>
  198. <customer-select ref="customer" @selectCustomer="selectCustomer" />
  199. </el-dialog>
  200. </div>
  201. </template>
  202. <script>
  203. import { listCard, getCard, delCard, addCard, updateCard, exportCard } from "@/api/company/companyUserCard";
  204. import addSms from './addSms.vue';
  205. import customerSelect from './customerSelect.vue';
  206. export default {
  207. name: "companyUserCard",
  208. components:{ addSms,customerSelect},
  209. watch: {
  210. imageArr: function(val) {
  211. this.form.imageUrl = val.join(',')
  212. },
  213. },
  214. data() {
  215. return {
  216. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  217. baseUrl: process.env.VUE_APP_BASE_API,
  218. // 遮罩层
  219. loading: true,
  220. // 选中数组
  221. ids: [],
  222. // 非单个禁用
  223. single: true,
  224. // 非多个禁用
  225. multiple: true,
  226. // 显示搜索条件
  227. showSearch: true,
  228. // 总条数
  229. total: 0,
  230. // card表格数据
  231. cardList: [],
  232. // 弹出层标题
  233. title: "",
  234. // 是否显示弹出层
  235. open: false,
  236. imageArr:[],
  237. // 查询参数
  238. queryParams: {
  239. pageNum: 1,
  240. pageSize: 10,
  241. title: null,
  242. userId: null,
  243. urlScheme: null,
  244. companyId: null,
  245. imageUrl: null,
  246. type: null,
  247. shortUrl: null,
  248. isVisit: null,
  249. lookNum: null,
  250. personNum: null,
  251. ipNum: null,
  252. },
  253. typeOptions:[],
  254. addSms:{
  255. open:false,
  256. title:"发短信"
  257. },
  258. customer:{
  259. open:false,
  260. title:"选择客户"
  261. },
  262. // 表单参数
  263. form: {},
  264. // 表单校验
  265. rules: {
  266. userId: [
  267. { required: true, message: "用户ID不能为空", trigger: "blur" }
  268. ],
  269. }
  270. };
  271. },
  272. created() {
  273. this.getDicts("company_user_card_type").then((response) => {
  274. this.typeOptions = response.data;
  275. });
  276. this.getList();
  277. },
  278. methods: {
  279. /** 查询card列表 */
  280. getList() {
  281. this.loading = true;
  282. listCard(this.queryParams).then(response => {
  283. this.cardList = response.rows;
  284. this.total = response.total;
  285. this.loading = false;
  286. });
  287. },
  288. // 取消按钮
  289. cancel() {
  290. this.open = false;
  291. this.reset();
  292. },
  293. // 表单重置
  294. reset() {
  295. this.form = {
  296. id: null,
  297. title: null,
  298. userId: null,
  299. urlScheme: null,
  300. companyId: null,
  301. imageUrl: null,
  302. type: "0",
  303. shortUrl: null,
  304. isVisit: null,
  305. lookNum: null,
  306. personNum: null,
  307. ipNum: null,
  308. createBy: null,
  309. createTime: null,
  310. updateBy: null,
  311. updateTime: null
  312. };
  313. this.resetForm("form");
  314. },
  315. /** 搜索按钮操作 */
  316. handleQuery() {
  317. this.queryParams.pageNum = 1;
  318. this.getList();
  319. },
  320. /** 重置按钮操作 */
  321. resetQuery() {
  322. this.resetForm("queryForm");
  323. this.handleQuery();
  324. },
  325. // 多选框选中数据
  326. handleSelectionChange(selection) {
  327. this.ids = selection.map(item => item.id)
  328. this.single = selection.length!==1
  329. this.multiple = !selection.length
  330. },
  331. /** 新增按钮操作 */
  332. handleAdd() {
  333. this.reset();
  334. this.open = true;
  335. this.title = "添加名片";
  336. },
  337. /** 修改按钮操作 */
  338. handleUpdate(row) {
  339. this.reset();
  340. const id = row.id || this.ids
  341. getCard(id).then(response => {
  342. this.form = response.data;
  343. if(this.form.type!=null){
  344. this.form.type = this.form.type.toString();
  345. }
  346. this.open = true;
  347. this.title = "修改个人名片";
  348. });
  349. },
  350. /** 提交按钮 */
  351. submitForm() {
  352. this.$refs["form"].validate(valid => {
  353. if (valid) {
  354. if (this.form.id != null) {
  355. updateCard(this.form).then(response => {
  356. if (response.code === 200) {
  357. this.msgSuccess("修改成功");
  358. this.open = false;
  359. this.getList();
  360. }
  361. });
  362. } else {
  363. addCard(this.form).then(response => {
  364. if (response.code === 200) {
  365. this.msgSuccess("新增成功");
  366. this.open = false;
  367. this.getList();
  368. }
  369. });
  370. }
  371. }
  372. });
  373. },
  374. /** 删除按钮操作 */
  375. handleDelete(row) {
  376. const ids = row.id || this.ids;
  377. this.$confirm('是否确认删除编号为"' + ids + '"的数据项?', "警告", {
  378. confirmButtonText: "确定",
  379. cancelButtonText: "取消",
  380. type: "warning"
  381. }).then(function() {
  382. return delCard(ids);
  383. }).then(() => {
  384. this.getList();
  385. this.msgSuccess("删除成功");
  386. }).catch(function() {});
  387. },
  388. /** 导出按钮操作 */
  389. handleExport() {
  390. const queryParams = this.queryParams;
  391. this.$confirm('是否确认导出所有数据项?', "警告", {
  392. confirmButtonText: "确定",
  393. cancelButtonText: "取消",
  394. type: "warning"
  395. }).then(function() {
  396. return exportCard(queryParams);
  397. }).then(response => {
  398. this.download(response.msg);
  399. }).catch(function() {});
  400. },
  401. handleSms(item){
  402. this.addSms.open=true;
  403. var that=this;
  404. setTimeout(() => {
  405. that.$refs.sms.reset(item.shortUrl);
  406. }, 500);
  407. },
  408. closeSms(){
  409. this.addSms.open=false;
  410. },
  411. selectCustomer(row){
  412. this.$refs.sms.selectCustomer(row);
  413. },
  414. handleAddCustomer(){
  415. this.customer.open=true;
  416. },
  417. handleAvatarSuccess(res, file) {
  418. if(res.code==200){
  419. this.form.imageUrl=res.url;
  420. }
  421. else{
  422. this.msgError(res.msg);
  423. }
  424. },
  425. beforeAvatarUpload(file) {
  426. const isLt1M = file.size / 1024 / 1024 < 1;
  427. if (!isLt1M) {
  428. this.$message.error('上传图片大小不能超过 1MB!');
  429. }
  430. return isLt1M;
  431. },
  432. }
  433. };
  434. </script>