phone.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. 添加物业电话(
  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="11"
  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. // 删除弹框信息
  120. deleteName: '',
  121. dialogVisibleDelete: false,
  122. // 添加弹框信息
  123. ruleForm: {
  124. communityList: '',
  125. newManagementName: '',
  126. newPhone: ''
  127. },
  128. rules: {
  129. communityList: [{ required: true, message: '请选择社区', trigger: 'change' }],
  130. newManagementName: [
  131. { required: true, message: '请输入管理处名称', trigger: 'blur' },
  132. { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }
  133. ],
  134. newPhone: [this.$valid.patternPhoneNumber()]
  135. },
  136. // 输入地址
  137. location: '',
  138. //社区列表
  139. communityListCreate: [],
  140. cols: [
  141. {
  142. label: '所属社区',
  143. prop: 'communityId',
  144. format(val) {
  145. let va = '';
  146. _this.$store.getters['getAreaSelect'].forEach((element) => {
  147. if (element.id === val) {
  148. va = element.communityName;
  149. }
  150. });
  151. return va;
  152. }
  153. },
  154. {
  155. label: '管理处名称',
  156. prop: 'name'
  157. },
  158. {
  159. label: '电话',
  160. prop: 'telephone'
  161. },
  162. {
  163. label: '操作',
  164. prop: 'id',
  165. slot: 'opt'
  166. }
  167. ],
  168. mixins_post: 'post',
  169. // 显隐弹框
  170. centerDialogVisible: false,
  171. // 编辑按钮
  172. enditShow: false,
  173. // 删除的id
  174. rowId: ''
  175. };
  176. },
  177. created() {
  178. this.getCommunityList();
  179. this.mixins_dataUrl = '/sc-community-web/property/telephone/page';
  180. this.mixins_query = {};
  181. this.mixins_search();
  182. },
  183. mounted() {},
  184. methods: {
  185. //**添加按钮 */
  186. add() {
  187. this.centerDialogVisible = true;
  188. this.enditShow = false;
  189. },
  190. /**查询按钮*/
  191. searchInfo() {
  192. if (this.location) {
  193. if (isNaN(this.location)) {
  194. this.mixins_query.name = this.location;
  195. } else {
  196. this.mixins_query.telephone = this.location;
  197. }
  198. }
  199. this.mixins_search();
  200. },
  201. /**
  202. * 弹框按钮
  203. * @param type 类型
  204. * @return {void}
  205. * */
  206. dialogButton(type) {
  207. if (type == 'addSave') {
  208. this.$refs['ruleForm'].validate((valid) => {
  209. if (valid) {
  210. if (this.ruleForm.newManagementName && this.ruleForm.newManagementName.indexOf('中心') != -1) {
  211. return this.$message.warning('不能包含中心');
  212. }
  213. let query = {
  214. communityId: this.ruleForm.communityList,
  215. name: this.ruleForm.newManagementName,
  216. telephone: this.ruleForm.newPhone,
  217. id: this.ruleForm.id
  218. };
  219. if (type === 'addSave') {
  220. console.log('query', query);
  221. if (!this.enditShow) {
  222. this.$http.post('/sc-community-web/property/telephone/add', query).then((res) => {
  223. this.message(res.status, '添加');
  224. this.$refs['ruleForm'].resetFields();
  225. });
  226. console.log('点击保存', this.ruleForm);
  227. }
  228. // this.centerDialogVisible=false;
  229. else {
  230. this.$http.post('/sc-community-web/property/telephone/update', query).then((res) => {
  231. this.message(res.status, '修改');
  232. });
  233. }
  234. } else {
  235. this.$refs['ruleForm'].resetFields();
  236. this.centerDialogVisible = false;
  237. }
  238. } else {
  239. return false;
  240. }
  241. });
  242. } else {
  243. this.centerDialogVisible = false;
  244. this.$refs['ruleForm'].resetFields();
  245. }
  246. },
  247. // 删除按钮
  248. deletes() {
  249. let query = {
  250. id: this.rowId
  251. };
  252. this.$http.get('/sc-community-web/property/telephone/delete', query).then((res) => {
  253. this.message(res.status, '删除');
  254. });
  255. },
  256. // 提示消息
  257. message(status, text) {
  258. if (status === 0) {
  259. this.$message({
  260. message: `${text}成功`,
  261. type: 'success'
  262. });
  263. this.centerDialogVisible = false;
  264. this.dialogVisibleDelete = false;
  265. this.mixins_search();
  266. } else {
  267. this.$message({
  268. message: `${text}失败请稍后重试`,
  269. type: 'warning'
  270. });
  271. }
  272. },
  273. /** 获取社区列表*/
  274. getCommunityList() {
  275. this.communityListCreate = [];
  276. let onOption = '';
  277. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  278. console.log('获取社区列表', res);
  279. this.$store.commit('setAreaSelect', res.data);
  280. res.data.map((item) => {
  281. onOption = {
  282. label: item.communityName,
  283. id: item.id
  284. };
  285. this.communityListCreate.push(onOption);
  286. });
  287. // console.log('this.communityListCreate', this.communityListCreate);
  288. });
  289. },
  290. /** 查看处理详情*/
  291. clickEdit(type, row) {
  292. console.log('查看处理详情', row);
  293. let communityId = row.communityId;
  294. var that = this;
  295. this.$store.getters['getAreaSelect'].forEach((element) => {
  296. if (element.id === communityId) {
  297. that.ruleForm.communityList = element.communityName;
  298. }
  299. });
  300. this.ruleForm.newManagementName = row.name;
  301. this.ruleForm.newPhone = row.telephone;
  302. this.ruleForm.id = row.id;
  303. this.rowId = row.id;
  304. if (type == 'endit') {
  305. this.centerDialogVisible = true;
  306. this.enditShow = true;
  307. } else {
  308. // this.deleteName = row.telephone;
  309. // this.dialogVisibleDelete = true;
  310. const { communityName, buildingName, unitName, roomNumber } = row;
  311. // let title = `是否确定删除对应的记录${communityName}${buildingName}${unitName}${telephone}”`;
  312. let title = `是否确定删除对应的记录`;
  313. this.$msgBox(title)
  314. .then(() => {
  315. let query = {
  316. id: this.rowId
  317. };
  318. this.$http
  319. .get('/sc-community-web/property/telephone/delete', query)
  320. .then(({ status, msg }) => {
  321. if (0 === status) {
  322. this.$message.success(msg);
  323. this.mixins_search();
  324. } else {
  325. this.$message.error(msg);
  326. }
  327. })
  328. .catch(() => {});
  329. })
  330. .catch(() => {});
  331. }
  332. }
  333. }
  334. };
  335. </script>
  336. <style lang="scss" scoped>
  337. @import './style.scss';
  338. </style>