index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
  4. <el-form-item label="组名称" prop="groupname">
  5. <el-input
  6. v-model="queryParams.groupname"
  7. placeholder="请输入组名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="人员账号" prop="accounts">
  14. <el-input
  15. v-model="queryParams.accounts"
  16. placeholder="请输入人员账号"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="人员姓名" prop="accountNames">
  23. <el-input
  24. v-model="queryParams.accountNames"
  25. placeholder="请输入人员姓名"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. icon="el-icon-plus"
  41. size="mini"
  42. @click="handleAdd"
  43. v-hasPermi="['system:contacts:add']"
  44. >新增</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="success"
  49. icon="el-icon-edit"
  50. size="mini"
  51. :disabled="single"
  52. @click="handleUpdate"
  53. v-hasPermi="['system:contacts:edit']"
  54. >修改</el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button
  58. type="danger"
  59. icon="el-icon-delete"
  60. size="mini"
  61. :disabled="multiple"
  62. @click="handleDelete"
  63. v-hasPermi="['system:contacts:remove']"
  64. >删除</el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. icon="el-icon-download"
  70. size="mini"
  71. @click="handleExport"
  72. v-hasPermi="['system:contacts:export']"
  73. >导出</el-button>
  74. </el-col>
  75. </el-row>
  76. <el-table :data="contactsList" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center" />
  78. <el-table-column label="分组id" align="center" prop="id" />
  79. <el-table-column label="组名称" align="center" prop="groupname" />
  80. <el-table-column label="人员账号" align="center" prop="accounts" />
  81. <el-table-column label="人员姓名" align="center" prop="accountNames" />
  82. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  83. <template slot-scope="scope">
  84. <el-button
  85. size="mini"
  86. type="text"
  87. icon="el-icon-edit"
  88. @click="handleUpdate(scope.row)"
  89. v-hasPermi="['system:contacts:edit']"
  90. >修改</el-button>
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-delete"
  95. @click="handleDelete(scope.row)"
  96. v-hasPermi="['system:contacts:remove']"
  97. >删除</el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <pagination
  102. v-show="total>0"
  103. :total="total"
  104. :page.sync="queryParams.pageNum"
  105. :limit.sync="queryParams.pageSize"
  106. @pagination="getList"
  107. />
  108. <!-- 添加或修改常用联系人对话框append-to-body -->
  109. <el-dialog :title="title" :visible.sync="open" width="500px" :modal-append-to-body='false' append-to-body>
  110. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  111. <el-form-item label="组名称" prop="groupname">
  112. <el-input v-model="form.groupname" placeholder="请输入组名称" />
  113. </el-form-item>
  114. <el-form-item label="人员账号" prop="accounts">
  115. <el-input v-model="form.accounts" placeholder="请输入人员账号" />
  116. </el-form-item>
  117. <el-form-item label="人员姓名" prop="accountNames">
  118. <el-input v-model="form.accountNames" placeholder="请选择该分组下的联系人" >
  119. <template slot="append">
  120. <el-button
  121. type="primary"
  122. icon="el-icon-plus"
  123. size="mini"
  124. @click="handleSelect" >
  125. 选择人员</el-button>
  126. </template>
  127. </el-input>
  128. </el-form-item>
  129. </el-form>
  130. <!-- 选择人员对话框 -->
  131. <select-user-by-dept style="z-index: 2093;" ref="selectUserByDept" :title="childTitle" :open="childOpen" :inputName="childAccountnames" :inputAccount="childAccouts" @ok="selectOK" />
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="submitForm">确 定</el-button>
  134. <el-button @click="cancelp">取 消</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import { listContacts, getContacts, delContacts, addContacts, updateContacts, exportContacts } from "@/api/system/contacts";
  141. import SelectUserByDept from "@/components/SelectRen/selectUserByDept";
  142. export default {
  143. name: "Contacts",
  144. components: {SelectUserByDept},
  145. data() {
  146. return {
  147. // 遮罩层
  148. loading: true,
  149. // 选中数组
  150. ids: [],
  151. // 非单个禁用
  152. single: true,
  153. // 非多个禁用
  154. multiple: true,
  155. // 总条数
  156. total: 0,
  157. // 常用联系人表格数据
  158. contactsList: [],
  159. // 弹出层标题
  160. title: "",
  161. // 是否显示弹出层
  162. open: false,
  163. // 查询参数
  164. queryParams: {
  165. pageNum: 1,
  166. pageSize: 10,
  167. groupname: undefined,
  168. accounts: undefined,
  169. accountNames: undefined,
  170. },
  171. // 表单参数
  172. form: {},
  173. // 表单校验
  174. rules: {
  175. },
  176. childTitle:'',
  177. childOpen:false,
  178. childAccouts:'',
  179. childAccountnames:''
  180. };
  181. },
  182. created() {
  183. this.getList();
  184. },
  185. methods: {
  186. /** 查询常用联系人列表 */
  187. getList() {
  188. this.loading = true;
  189. listContacts(this.queryParams).then(response => {
  190. this.contactsList = response.rows;
  191. this.total = response.total;
  192. this.loading = false;
  193. });
  194. },
  195. // 取消按钮
  196. cancelp() {
  197. this.open = false;
  198. this.reset();
  199. this.childOpen=false;
  200. },
  201. // 表单重置
  202. reset() {
  203. this.form = {
  204. id: undefined,
  205. groupname: undefined,
  206. accounts: undefined,
  207. accountNames: undefined,
  208. createBy: undefined,
  209. createTime: undefined
  210. };
  211. this.resetForm("form");
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.resetForm("queryForm");
  221. this.handleQuery();
  222. },
  223. // 多选框选中数据
  224. handleSelectionChange(selection) {
  225. this.ids = selection.map(item => item.id)
  226. this.single = selection.length!=1
  227. this.multiple = !selection.length
  228. },
  229. /** 新增按钮操作 */
  230. handleAdd() {
  231. this.reset();
  232. this.open = true;
  233. this.title = "添加常用联系人";
  234. console.log("新增==="+this.open+"=="+this.childOpen+"=="+this.childAccouts+"=="+this.loading);
  235. this.childOpen=false;
  236. this.childTitle='';
  237. },
  238. /** 修改按钮操作 */
  239. handleUpdate(row) {
  240. this.reset();
  241. const id = row.id || this.ids
  242. getContacts(id).then(response => {
  243. this.form = response.data;
  244. this.open = true;
  245. this.title = "修改常用联系人";
  246. this.childAccouts = this.form.accounts;
  247. this.childAccountnames = this.form.accountNames;
  248. this.childOpen=false;
  249. this.childTitle='';
  250. });
  251. },
  252. /** 提交按钮 */
  253. submitForm: function() {
  254. this.$refs["form"].validate(valid => {
  255. if (valid) {
  256. if (this.form.id != undefined) {
  257. updateContacts(this.form).then(response => {
  258. if (response.code === 200) {
  259. this.msgSuccess("修改成功");
  260. this.open = false;
  261. this.getList();
  262. }
  263. });
  264. } else {
  265. addContacts(this.form).then(response => {
  266. if (response.code === 200) {
  267. this.msgSuccess("新增成功");
  268. this.open = false;
  269. this.getList();
  270. }
  271. });
  272. }
  273. }
  274. });
  275. },
  276. /** 删除按钮操作 */
  277. handleDelete(row) {
  278. const ids = row.id || this.ids;
  279. this.$confirm('是否确认删除常用联系人编号为"' + ids + '"的数据项?', "警告", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning"
  283. }).then(function() {
  284. return delContacts(ids);
  285. }).then(() => {
  286. this.getList();
  287. this.msgSuccess("删除成功");
  288. }).catch(function() {});
  289. },
  290. /** 导出按钮操作 */
  291. handleExport() {
  292. const queryParams = this.queryParams;
  293. this.$confirm('是否确认导出所有常用联系人数据项?', "警告", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning"
  297. }).then(function() {
  298. return exportContacts(queryParams);
  299. }).then(response => {
  300. this.download(response.msg);
  301. }).catch(function() {});
  302. },
  303. /** 新增或修改弹出框中的 选择人员 按钮弹窗操作 */
  304. handleSelect() {
  305. this.$refs.selectUserByDept.childOpen=true;
  306. this.childOpen = true;
  307. this.childTitle = "选择收件人";
  308. console.log("选择人员==="+this.open+"=="+this.childOpen+"=="+this.childAccouts+"=="+this.loading);
  309. },
  310. selectOK(zh, xm) {
  311. this.childAccouts=zh;
  312. this.childAccountnames=xm;
  313. this.form.accounts = zh;
  314. this.form.accountNames=xm;
  315. this.childOpen=false;
  316. }
  317. }
  318. };
  319. </script>
  320. <style scoped>
  321. /*.v-modal{*/
  322. /* z-index: 1800 !important;*/
  323. /*}*/
  324. /*.el-dialog__wrapper{*/
  325. /* z-index: 2093 !important;*/
  326. /*}*/
  327. </style>