index.vue 9.4 KB

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