index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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="家长ID" prop="customerId">
  5. <el-input
  6. v-model="queryParams.customerId"
  7. placeholder="请输入家长ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="销售ID" prop="companyUserId">
  14. <el-input
  15. v-model="queryParams.companyUserId"
  16. placeholder="请输入销售ID"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="标题" prop="title">
  23. <el-input
  24. v-model="queryParams.title"
  25. placeholder="请输入标题"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="日志类型" prop="logsType">
  32. <el-select v-model="queryParams.logsType" placeholder="请选择日志类型" clearable size="small">
  33. <el-option label="请选择字典生成" value="" />
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. icon="el-icon-plus"
  46. size="mini"
  47. @click="handleAdd"
  48. v-hasPermi="['crm:customerLogs:add']"
  49. >新增</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="success"
  54. icon="el-icon-edit"
  55. size="mini"
  56. :disabled="single"
  57. @click="handleUpdate"
  58. v-hasPermi="['crm:customerLogs:edit']"
  59. >修改</el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="danger"
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['crm:customerLogs:remove']"
  69. >删除</el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="warning"
  74. icon="el-icon-download"
  75. size="mini"
  76. @click="handleExport"
  77. v-hasPermi="['crm:customerLogs:export']"
  78. >导出</el-button>
  79. </el-col>
  80. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  81. </el-row>
  82. <el-table v-loading="loading" :data="customerLogsList" @selection-change="handleSelectionChange">
  83. <el-table-column type="selection" width="55" align="center" />
  84. <el-table-column label="ID" align="center" prop="logsId" />
  85. <el-table-column label="家长ID" align="center" prop="customerId" />
  86. <el-table-column label="销售ID" align="center" prop="companyUserId" />
  87. <el-table-column label="标题" align="center" prop="title" />
  88. <el-table-column label="备注" align="center" prop="remark" />
  89. <el-table-column label="日志类型" align="center" prop="logsType" />
  90. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  91. <template slot-scope="scope">
  92. <el-button
  93. size="mini"
  94. type="text"
  95. icon="el-icon-edit"
  96. @click="handleUpdate(scope.row)"
  97. v-hasPermi="['crm:customerLogs:edit']"
  98. >修改</el-button>
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-delete"
  103. @click="handleDelete(scope.row)"
  104. v-hasPermi="['crm:customerLogs:remove']"
  105. >删除</el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <pagination
  110. v-show="total>0"
  111. :total="total"
  112. :page.sync="queryParams.pageNum"
  113. :limit.sync="queryParams.pageSize"
  114. @pagination="getList"
  115. />
  116. <!-- 添加或修改家长日志对话框 -->
  117. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  118. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  119. <el-form-item label="家长ID" prop="customerId">
  120. <el-input v-model="form.customerId" placeholder="请输入家长ID" />
  121. </el-form-item>
  122. <el-form-item label="销售ID" prop="companyUserId">
  123. <el-input v-model="form.companyUserId" placeholder="请输入销售ID" />
  124. </el-form-item>
  125. <el-form-item label="标题" prop="title">
  126. <el-input v-model="form.title" placeholder="请输入标题" />
  127. </el-form-item>
  128. <el-form-item label="备注" prop="remark">
  129. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  130. </el-form-item>
  131. <el-form-item label="日志类型" prop="logsType">
  132. <el-select v-model="form.logsType" placeholder="请选择日志类型">
  133. <el-option label="请选择字典生成" value="" />
  134. </el-select>
  135. </el-form-item>
  136. </el-form>
  137. <div slot="footer" class="dialog-footer">
  138. <el-button type="primary" @click="submitForm">确 定</el-button>
  139. <el-button @click="cancel">取 消</el-button>
  140. </div>
  141. </el-dialog>
  142. </div>
  143. </template>
  144. <script>
  145. import { listCustomerLogs, getCustomerLogs, delCustomerLogs, addCustomerLogs, updateCustomerLogs, exportCustomerLogs } from "@/api/crm/customerLogs";
  146. export default {
  147. name: "CustomerLogs",
  148. data() {
  149. return {
  150. // 遮罩层
  151. loading: true,
  152. // 选中数组
  153. ids: [],
  154. // 非单个禁用
  155. single: true,
  156. // 非多个禁用
  157. multiple: true,
  158. // 显示搜索条件
  159. showSearch: true,
  160. // 总条数
  161. total: 0,
  162. // 家长日志表格数据
  163. customerLogsList: [],
  164. // 弹出层标题
  165. title: "",
  166. // 是否显示弹出层
  167. open: false,
  168. // 查询参数
  169. queryParams: {
  170. pageNum: 1,
  171. pageSize: 10,
  172. customerId: null,
  173. companyUserId: null,
  174. title: null,
  175. logsType: null
  176. },
  177. // 表单参数
  178. form: {},
  179. // 表单校验
  180. rules: {
  181. }
  182. };
  183. },
  184. created() {
  185. this.getList();
  186. },
  187. methods: {
  188. /** 查询家长日志列表 */
  189. getList() {
  190. this.loading = true;
  191. listCustomerLogs(this.queryParams).then(response => {
  192. this.customerLogsList = response.rows;
  193. this.total = response.total;
  194. this.loading = false;
  195. });
  196. },
  197. // 取消按钮
  198. cancel() {
  199. this.open = false;
  200. this.reset();
  201. },
  202. // 表单重置
  203. reset() {
  204. this.form = {
  205. logsId: null,
  206. customerId: null,
  207. companyUserId: null,
  208. title: null,
  209. remark: null,
  210. createTime: null,
  211. logsType: null
  212. };
  213. this.resetForm("form");
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. resetQuery() {
  222. this.resetForm("queryForm");
  223. this.handleQuery();
  224. },
  225. // 多选框选中数据
  226. handleSelectionChange(selection) {
  227. this.ids = selection.map(item => item.logsId)
  228. this.single = selection.length!==1
  229. this.multiple = !selection.length
  230. },
  231. /** 新增按钮操作 */
  232. handleAdd() {
  233. this.reset();
  234. this.open = true;
  235. this.title = "添加家长日志";
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.reset();
  240. const logsId = row.logsId || this.ids
  241. getCustomerLogs(logsId).then(response => {
  242. this.form = response.data;
  243. this.open = true;
  244. this.title = "修改家长日志";
  245. });
  246. },
  247. /** 提交按钮 */
  248. submitForm() {
  249. this.$refs["form"].validate(valid => {
  250. if (valid) {
  251. if (this.form.logsId != null) {
  252. updateCustomerLogs(this.form).then(response => {
  253. if (response.code === 200) {
  254. this.msgSuccess("修改成功");
  255. this.open = false;
  256. this.getList();
  257. }
  258. });
  259. } else {
  260. addCustomerLogs(this.form).then(response => {
  261. if (response.code === 200) {
  262. this.msgSuccess("新增成功");
  263. this.open = false;
  264. this.getList();
  265. }
  266. });
  267. }
  268. }
  269. });
  270. },
  271. /** 删除按钮操作 */
  272. handleDelete(row) {
  273. const logsIds = row.logsId || this.ids;
  274. this.$confirm('是否确认删除家长日志编号为"' + logsIds + '"的数据项?', "警告", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning"
  278. }).then(function() {
  279. return delCustomerLogs(logsIds);
  280. }).then(() => {
  281. this.getList();
  282. this.msgSuccess("删除成功");
  283. }).catch(function() {});
  284. },
  285. /** 导出按钮操作 */
  286. handleExport() {
  287. const queryParams = this.queryParams;
  288. this.$confirm('是否确认导出所有家长日志数据项?', "警告", {
  289. confirmButtonText: "确定",
  290. cancelButtonText: "取消",
  291. type: "warning"
  292. }).then(function() {
  293. return exportCustomerLogs(queryParams);
  294. }).then(response => {
  295. this.download(response.msg);
  296. }).catch(function() {});
  297. }
  298. }
  299. };
  300. </script>