phone.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="phone">
  3. <div class="search">
  4. <el-input placeholder="请输入管理处名称/电话" maxlength="11" class="search-input" clearable v-model="location"></el-input>
  5. <el-select placeholder="请选择所属社区" v-model="mixins_query.communityId" clearable>
  6. <el-option v-for="(item, index) in communityListCreate" :key="index" :label="item.label" :value="item.id"></el-option>
  7. </el-select>
  8. <el-button type="primary" placeholder="状态" class="search-btn" @click="searchInfo" icon="el-icon-search" v-preventReClick
  9. >查询
  10. </el-button>
  11. <div class="add">
  12. <img src="../../assets/img/btn_tianjia@2x.png" alt="" @click="add" />
  13. </div>
  14. </div>
  15. <div class="content">
  16. <div class="roles-wrap">
  17. <zz-table
  18. :cols="cols"
  19. :settings="{ showNumber: true, stripe: true, showNumberWidth: '140' }"
  20. :data="mixins_list"
  21. :pageset="mixins_pageset"
  22. @page-change="pageChange"
  23. @selection-change="selectionChange"
  24. :loading="mixins_onQuery"
  25. >
  26. <template slot-scope="scope" slot="times">
  27. <div>
  28. {{ scope.row.time | filterTime }}
  29. </div>
  30. </template>
  31. <template slot-scope="scope" slot="opt">
  32. <div class="opt">
  33. <img src="../../assets/img/icon_bianji@2x.png" alt="" @click="clickEdit('endit', scope.row)" />
  34. <img src="../../assets/img/icon_shanchu@2x.png" alt="" @click="clickEdit('del', scope.row)" />
  35. </div>
  36. </template>
  37. </zz-table>
  38. </div>
  39. <!-- 详情弹框 -->
  40. <div class="dialog-info">
  41. <el-dialog :visible.sync="centerDialogVisible" width="524px">
  42. <div class="dialog">
  43. <div class="dialog-header">
  44. <i class="el-dialog__close el-icon el-icon-close" @click="dialogButton('clear')"></i>
  45. <div class="dialogTitle">
  46. {{ dialogTitle }}物业电话(
  47. <span style="color: red"> *</span>
  48. 为必填项)
  49. </div>
  50. </div>
  51. <div class="dialog-content">
  52. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  53. <el-form-item label="所属社区" prop="communityList">
  54. <el-select placeholder="请选择所属社区" v-model="ruleForm.communityList" class="dialog-select">
  55. <el-option
  56. v-for="(item, index) in communityListCreate"
  57. :key="index"
  58. :label="item.label"
  59. :value="item.id"
  60. >{{ item.label }}</el-option
  61. >
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="管理处名称" prop="newManagementName">
  65. <el-input
  66. v-model="ruleForm.newManagementName"
  67. placeholder="不能超过20字"
  68. @keyup.enter.native="dialogButton('addSave')"
  69. maxlength="20"
  70. ></el-input>
  71. </el-form-item>
  72. <el-form-item label="电话号码" prop="newPhone">
  73. <el-input
  74. v-model="ruleForm.newPhone"
  75. placeholder="例如:010-26888888,13888888888"
  76. maxlength="13"
  77. @keyup.enter.native="dialogButton('addSave')"
  78. ></el-input>
  79. </el-form-item>
  80. <el-form-item class="dialog-footer">
  81. <span>
  82. <el-button type="primary" @click="dialogButton('clear')" plain>取消</el-button>
  83. <el-button type="primary" @click="dialogButton('addSave')">保存</el-button>
  84. </span>
  85. </el-form-item>
  86. </el-form>
  87. </div>
  88. </div>
  89. </el-dialog>
  90. </div>
  91. <!-- 删除弹框 -->
  92. <div class="dialog-delete">
  93. <el-dialog title="确认提示" :visible.sync="dialogVisibleDelete" width="30%">
  94. <div class="dialog-deletecontent">
  95. <img src="../../assets/img/icon-warning.png" alt="" class="dialog-icon" />
  96. <div>
  97. <p>确认删除</p>
  98. <p>
  99. 是否删除对应的记录 &nbsp;---&nbsp;<span class="delete-name">{{ deleteName }}</span>
  100. </p>
  101. </div>
  102. </div>
  103. <span slot="footer" class="dialog-footer">
  104. <el-button @click="dialogVisibleDelete = false" type="primary" plain>取 消</el-button>
  105. <el-button type="primary" @click="deletes">确 定</el-button>
  106. </span>
  107. </el-dialog>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. import list from '@utils/list.js';
  114. export default {
  115. mixins: [list],
  116. data() {
  117. let _this = this;
  118. return {
  119. dialogTitle: '',
  120. // 删除弹框信息
  121. deleteName: '',
  122. dialogVisibleDelete: false,
  123. // 添加弹框信息
  124. ruleForm: {
  125. communityList: '',
  126. newManagementName: '',
  127. newPhone: ''
  128. },
  129. rules: {
  130. communityList: [{ required: true, message: '请选择社区', trigger: 'change' }],
  131. newManagementName: [
  132. { required: true, message: '请输入管理处名称', trigger: 'blur' },
  133. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }
  134. ],
  135. newPhone: [this.$valid.patternPhoneNumber()]
  136. },
  137. // 输入地址
  138. location: '',
  139. //社区列表
  140. communityListCreate: [],
  141. cols: [
  142. {
  143. label: '所属社区',
  144. prop: 'communityId',
  145. format(val) {
  146. let va = '';
  147. _this.$store.getters['getAreaSelect'].forEach((element) => {
  148. if (element.id === val) {
  149. va = element.communityName;
  150. }
  151. });
  152. return va;
  153. }
  154. },
  155. {
  156. label: '管理处名称',
  157. prop: 'name'
  158. },
  159. {
  160. label: '电话',
  161. prop: 'telephone'
  162. },
  163. {
  164. label: '操作',
  165. prop: 'id',
  166. slot: 'opt'
  167. }
  168. ],
  169. mixins_post: 'post',
  170. // 显隐弹框
  171. centerDialogVisible: false,
  172. // 编辑按钮
  173. enditShow: false,
  174. // 删除的id
  175. rowId: ''
  176. };
  177. },
  178. created() {
  179. this.getCommunityList();
  180. this.mixins_dataUrl = '/sc-community-web/property/telephone/page';
  181. this.mixins_query = {};
  182. this.mixins_search();
  183. },
  184. mounted() {},
  185. methods: {
  186. //**添加按钮 */
  187. add() {
  188. this.dialogTitle = '添加';
  189. this.centerDialogVisible = true;
  190. this.enditShow = false;
  191. this.$refs['ruleForm'].resetFields();
  192. },
  193. /**查询按钮*/
  194. searchInfo() {
  195. this.mixins_query.name = '';
  196. this.mixins_query.telephone = '';
  197. if (this.location) {
  198. if (isNaN(this.location)) {
  199. this.mixins_query.name = this.location;
  200. } else {
  201. this.mixins_query.telephone = this.location;
  202. }
  203. }
  204. this.mixins_search();
  205. },
  206. /**
  207. * 弹框按钮
  208. * @param type 类型
  209. * @return {void}
  210. * */
  211. dialogButton(type) {
  212. if (type == 'addSave') {
  213. this.$refs['ruleForm'].validate((valid) => {
  214. if (valid) {
  215. // if (this.ruleForm.newManagementName && this.ruleForm.newManagementName.indexOf('中心') != -1) {
  216. // return this.$message.warning('不能包含中心');
  217. // }
  218. let query = {
  219. communityId: this.ruleForm.communityList,
  220. name: this.ruleForm.newManagementName,
  221. telephone: this.ruleForm.newPhone,
  222. id: this.ruleForm.id
  223. };
  224. if (type === 'addSave') {
  225. console.log('query', query);
  226. if (!this.enditShow) {
  227. this.$http.post('/sc-community-web/property/telephone/add', query).then((res) => {
  228. this.message(res.status, '添加');
  229. this.$refs['ruleForm'].resetFields();
  230. });
  231. console.log('点击保存', this.ruleForm);
  232. }
  233. // this.centerDialogVisible=false;
  234. else {
  235. this.$http.post('/sc-community-web/property/telephone/update', query).then((res) => {
  236. this.message(res.status, '修改');
  237. });
  238. }
  239. } else {
  240. this.centerDialogVisible = false;
  241. this.$refs['ruleForm'].resetFields();
  242. }
  243. } else {
  244. return false;
  245. }
  246. });
  247. } else {
  248. this.centerDialogVisible = false;
  249. this.$refs['ruleForm'].resetFields();
  250. }
  251. },
  252. // 删除按钮
  253. deletes() {
  254. let query = {
  255. id: this.rowId
  256. };
  257. this.$http.get('/sc-community-web/property/telephone/delete', query).then((res) => {
  258. this.message(res.status, '删除');
  259. });
  260. },
  261. // 提示消息
  262. message(status, text) {
  263. if (status === 0) {
  264. this.$message({
  265. message: `${text}成功`,
  266. type: 'success'
  267. });
  268. this.centerDialogVisible = false;
  269. this.dialogVisibleDelete = false;
  270. this.mixins_search();
  271. } else {
  272. this.$message({
  273. message: `${text}失败请稍后重试`,
  274. type: 'warning'
  275. });
  276. }
  277. },
  278. /** 获取社区列表*/
  279. getCommunityList() {
  280. this.communityListCreate = [];
  281. let onOption = '';
  282. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  283. console.log('获取社区列表', res);
  284. this.$store.commit('setAreaSelect', res.data);
  285. res.data.map((item) => {
  286. onOption = {
  287. label: item.communityName,
  288. id: item.id
  289. };
  290. this.communityListCreate.push(onOption);
  291. });
  292. // console.log('this.communityListCreate', this.communityListCreate);
  293. });
  294. },
  295. /** 查看处理详情*/
  296. clickEdit(type, row) {
  297. this.dialogTitle = '编辑';
  298. console.log('查看处理详情', row);
  299. let communityId = row.communityId;
  300. var that = this;
  301. this.$store.getters['getAreaSelect'].forEach((element) => {
  302. if (element.id === communityId) {
  303. that.ruleForm.communityList = element.communityName;
  304. }
  305. });
  306. this.ruleForm.newManagementName = row.name;
  307. this.ruleForm.newPhone = row.telephone;
  308. this.ruleForm.id = row.id;
  309. this.rowId = row.id;
  310. if (type == 'endit') {
  311. this.centerDialogVisible = true;
  312. this.enditShow = true;
  313. } else {
  314. // this.deleteName = row.telephone;
  315. // this.dialogVisibleDelete = true;
  316. const { communityName, buildingName, unitName, roomNumber } = row;
  317. // let title = `是否确定删除对应的记录${communityName}${buildingName}${unitName}${telephone}”`;
  318. let title = `是否确定删除对应的记录`;
  319. this.$msgBox(title)
  320. .then(() => {
  321. let query = {
  322. id: this.rowId
  323. };
  324. this.$http
  325. .get('/sc-community-web/property/telephone/delete', query)
  326. .then(({ status, msg }) => {
  327. if (0 === status) {
  328. this.$message.success(msg);
  329. this.mixins_search();
  330. } else {
  331. this.$message.error(msg);
  332. }
  333. })
  334. .catch(() => {});
  335. })
  336. .catch(() => {});
  337. }
  338. }
  339. }
  340. };
  341. </script>
  342. <style lang="scss" scoped>
  343. @import './style.scss';
  344. </style>