index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <?
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('index', __DIR__);
  4. ?>
  5. <style>
  6. .distrow {
  7. height: 50px !important;
  8. }
  9. .distpopup {
  10. position: absolute;
  11. right: -2px;
  12. top: -4px;
  13. background: #fff;
  14. box-shadow: 7px 5px 11px grey;
  15. width: 83px;
  16. z-index: 5;
  17. }
  18. </style>
  19. <div id="app" v-cloak>
  20. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  21. <div slot="header">
  22. <div>
  23. <span>社区列表</span>
  24. <div style="float: right;margin-top: -5px">
  25. <el-button type="primary" @click="add" size="small">添加社区</el-button>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="table-body">
  30. <div style="padding-bottom: 20px;">
  31. <div class="flex">
  32. <div class="flex" style="margin-right: 20px;">
  33. <div class="input-title" style="flex-shrink: 0;">省级/直辖市名称</div>
  34. <el-input size="small" style="width: 130px;" placeholder="请输入省级/直辖市名称" v-model="searchData.province_name"> </el-input>
  35. </div>
  36. <div class="flex" style="margin-right: 20px;">
  37. <div class="input-title" style="flex-shrink: 0;">市级名称</div>
  38. <el-input size="small" style="width: 130px;" placeholder="请输入市级名称" v-model="searchData.city_name">
  39. </el-input>
  40. </div>
  41. <div class="flex" style="margin-right: 20px;">
  42. <div class="input-title" style="flex-shrink: 0;">区级/县级名称</div>
  43. <el-input size="small" style="width: 130px;" placeholder="请输入区级/县级名称" v-model="searchData.district_name">
  44. </el-input>
  45. </div>
  46. <div class="flex" style="margin-right: 20px;">
  47. <div class="input-title" style="flex-shrink: 0;">街道/镇/乡名称</div>
  48. <el-input size="small" style="width: 140px;" placeholder="请输入街道/镇/乡名称" v-model="searchData.street_name">
  49. </el-input>
  50. </div>
  51. <div class="flex" style="margin-right: 20px;">
  52. <div class="input-title" style="flex-shrink: 0;">社区名称</div>
  53. <el-input size="small" style="width: 130px;" placeholder="请输入社区名称" v-model="searchData.community_name">
  54. </el-input>
  55. </div>
  56. <el-button style="padding: 9px 15px !important;" size="small" type="primary" @click="searchs">搜索</el-button>
  57. <el-button type="warning" @click="clereSearch" v-if="searchData.province_name || searchData.city_name || searchData.district_name || searchData.street_name || searchData.community_name" style="padding: 9px 15px !important;">清除搜索条件</el-button>
  58. </div>
  59. </div>
  60. <el-table :data="communityList" stripe v-loading="loading" size="small" style="margin-bottom: 15px; width: 100%">
  61. <el-table-column label="省级/直辖市" width="150" prop="province_name">
  62. <template slot-scope="scope">
  63. <div class="user_img" flex="cross:center">
  64. <div>{{scope.row.province_name}}</div>
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="市级" prop="city_name" width="200" align="center">
  69. <template slot-scope="scope">
  70. <div>{{scope.row.city_name}}</div>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="区级/县级" prop="district_name" width="200" align="center">
  74. <template slot-scope="scope">
  75. <div>{{scope.row.district_name}}</div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="乡/镇/街道" prop="street_name" width="200" align="center">
  79. <template slot-scope="scope">
  80. <div>{{scope.row.street_name}}</div>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="社区" prop="community_name" align="center">
  84. <template slot-scope="scope">
  85. <div> <span>{{scope.row.community_name}}</span> </div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="创建时间" prop="updated_at" align="center">
  89. <template slot-scope="scope">
  90. <div>
  91. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  92. </div>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="更新时间" prop="updated_at" align="center">
  96. <template slot-scope="scope">
  97. <div>
  98. {{scope.row.updated_at|dateTimeFormat('Y-m-d H:i:s')}}
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="操作" prop="action" align="center">
  103. <template slot-scope="scope">
  104. <el-button type="text" size="small" @click="editStoreCommunity(scope.row)">编辑</el-button>
  105. <el-button type="text" size="small" @click="deleteStoreCommunity(scope.row)">删除</el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <div style="text-align: right;margin: 20px 0;">
  110. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  111. </div>
  112. </div>
  113. </el-card>
  114. <el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose" :close-on-click-modal="false">
  115. <template>
  116. <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="100px"
  117. @submit.native.prevent>
  118. <el-card shadow="never">
  119. <el-col :span="50">
  120. <el-form-item label="社区名称" prop="community_name">
  121. <el-input v-model="ruleForm.community_name" placeholder="请输入社区名称,最多20个字"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. </el-card>
  125. <div style="display: flex;justify-content: end">
  126. <el-button :loading="btnLoading" class="button-item" style="margin-top: 24px;"
  127. @click="handleCancel" size="small">取消
  128. </el-button>
  129. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
  130. @click="editForm('ruleForm')" size="small">确定
  131. </el-button>
  132. </div>
  133. </el-form>
  134. </template>
  135. </el-dialog>
  136. </div>
  137. <script>
  138. const app = new Vue({
  139. el: '#app',
  140. data: {
  141. searchData: {
  142. province_name: '',
  143. city_name: '',
  144. district_name: '',
  145. street_name: '',
  146. community_name: '',
  147. start_time: '',
  148. end_time: '',
  149. },
  150. ruleForm:{
  151. 'community_name':''
  152. },
  153. btnLoad: false,
  154. btnLoading:false,
  155. dialog: {
  156. createUpload: false,
  157. execLog: false,
  158. },
  159. rules: {
  160. name: [{
  161. required: true,
  162. message: '请输入社区名称',
  163. trigger: 'change'
  164. },
  165. {
  166. validator: (rule, value, callback) => {
  167. if (value.length > 20 || value.length < 0) {
  168. callback('最大长度在1-20个字内');
  169. }
  170. callback();
  171. }
  172. },
  173. ],
  174. },
  175. dates: null,
  176. currPage: 1,
  177. pageCount: 0,
  178. loading: false,
  179. communityList: [],
  180. dialogLoading: false,
  181. dialogVisible: false,
  182. },
  183. mounted() {
  184. this.loadData();
  185. },
  186. methods: {
  187. searchs() {
  188. this.currPage = 1;
  189. this.loadData();
  190. },
  191. handleCancel() {
  192. this.dialogVisible = false; // 关闭弹框
  193. // 可以在这里添加更多的取消逻辑
  194. },
  195. clereSearch() {
  196. this.searchData.province_name = '';
  197. this.searchData.city_name = '';
  198. this.searchData.district_name = '';
  199. this.searchData.street_name = '';
  200. this.searchData.community_name = '';
  201. this.currPage = 1;
  202. this.loadData();
  203. },
  204. // 选中时间
  205. selectedDates(e) {
  206. if (e) {
  207. this.searchData.start_time = e[0];
  208. this.searchData.end_time = e[1];
  209. } else {
  210. this.searchData.start_time = '';
  211. this.searchData.end_time = '';
  212. }
  213. this.currPage = 1;
  214. this.loadData();
  215. },
  216. // 标签页切换
  217. handleTabClick(e) {
  218. this.loadData();
  219. },
  220. loadData() {
  221. this.loading = true;
  222. request({
  223. params: {
  224. r: 'store/store-community/index',
  225. page: this.currPage,
  226. ...this.searchData,
  227. },
  228. method: 'get',
  229. }).then(e => {
  230. this.loading = false;
  231. console.log(e.data)
  232. if (e.status == 200) {
  233. this.communityList = e.data.data.list;
  234. this.pageCount = e.data.data.page_count;
  235. } else {
  236. this.$message.error(e.data.msg);
  237. }
  238. }).catch(e => {
  239. console.log('错误信息为',e)
  240. this.loading = false;
  241. });
  242. },
  243. // 编辑
  244. add(id) {
  245. navigateTo({
  246. r: 'store/store-community/add',
  247. });
  248. },
  249. editStoreCommunity(e){
  250. this.ruleForm.community_name = e.community_name;
  251. this.ruleForm.province_id = e.province_id;
  252. this.ruleForm.city_id = e.city_id;
  253. this.ruleForm.district_id = e.district_id;
  254. this.ruleForm.street_id = e.street_id;
  255. this.ruleForm.community_id = e.id;
  256. this.dialogVisible = true;
  257. },
  258. handleClose(done) {
  259. done();
  260. },
  261. deleteStoreCommunity(e){
  262. this.loading = true;
  263. this.$confirm('此操作将删除社区, 是否继续?', '提示', {
  264. confirmButtonText: '确定',
  265. cancelButtonText: '取消',
  266. type: 'warning'
  267. }).then(() => {
  268. request({
  269. params: {
  270. r: 'store/store-community/delete',
  271. },
  272. method: 'post',
  273. data: {
  274. community_id: e.id,
  275. }
  276. }).then(e => {
  277. if (e.data.code == 0) {
  278. this.loading = false;
  279. this.$message.success(e.data.msg);
  280. this.dialogVisible = false;
  281. this.loadData();
  282. } else {
  283. this.$message.error(e.data.msg);
  284. }
  285. }).catch(e => {
  286. console.log('报错信息为:')
  287. console.log(e)
  288. this.$message.error(e);
  289. })
  290. }).catch(() => {
  291. this.loading = false;
  292. this.$message({
  293. type: 'info',
  294. message: '已取消删除'
  295. });
  296. });
  297. },
  298. editForm(){
  299. this.loading = true;
  300. request({
  301. params: {
  302. r: 'store/store-community/edit',
  303. },
  304. method: 'post',
  305. data: {
  306. form: this.ruleForm,
  307. }
  308. }).then(e => {
  309. if (e.data.code == 0) {
  310. this.$message.success(e.data.msg);
  311. this.dialogVisible = false;
  312. this.loadData();
  313. } else {
  314. this.$message.error(e.data.msg);
  315. }
  316. }).catch(e => {
  317. console.log('报错信息为:')
  318. console.log(e)
  319. this.$message.error(e);
  320. })
  321. },
  322. pagination(currentPage) {
  323. let self = this;
  324. self.currPage = currentPage;
  325. self.loadData();
  326. }
  327. }
  328. });
  329. </script>
  330. <style>
  331. .el-tabs__header {
  332. font-size: 16px;
  333. }
  334. .table-body {
  335. padding: 20px;
  336. background-color: #fff;
  337. }
  338. .input-item {
  339. width: 250px;
  340. margin-right: 40px;
  341. }
  342. .input-item .el-input__inner {
  343. border-right: 0;
  344. }
  345. .input-item .el-input__inner:hover {
  346. border: 1px solid #dcdfe6;
  347. border-right: 0;
  348. outline: 0;
  349. }
  350. .input-item .el-input__inner:focus {
  351. border: 1px solid #dcdfe6;
  352. border-right: 0;
  353. outline: 0;
  354. }
  355. .input-item .el-input-group__append {
  356. background-color: #fff;
  357. border-left: 0;
  358. width: 10%;
  359. padding: 0;
  360. }
  361. .input-item .el-input-group__append .el-button {
  362. padding: 0;
  363. }
  364. .input-item .el-input-group__append .el-button {
  365. margin: 0;
  366. }
  367. .table-body {
  368. padding: 20px;
  369. background-color: #fff;
  370. }
  371. .table-body .el-button {
  372. /* padding: 0 !important; */
  373. padding: 9px;
  374. border: 0;
  375. margin: 0 5px;
  376. }
  377. .input-item {
  378. width: 250px;
  379. margin: 0 0 20px;
  380. display: inline-block;
  381. }
  382. .input-item .el-input__inner {
  383. border-right: 0;
  384. }
  385. .input-item .el-input__inner:hover {
  386. border: 1px solid #dcdfe6;
  387. border-right: 0;
  388. outline: 0;
  389. }
  390. .input-item .el-input__inner:focus {
  391. border: 1px solid #dcdfe6;
  392. border-right: 0;
  393. outline: 0;
  394. }
  395. .input-item .el-input-group__append {
  396. background-color: #fff;
  397. border-left: 0;
  398. width: 10%;
  399. padding: 0;
  400. }
  401. .input-item .el-input-group__append .el-button {
  402. padding: 0;
  403. }
  404. .input-item .el-input-group__append .el-button {
  405. margin: 0;
  406. }
  407. .batch {
  408. margin: 0 0 20px;
  409. display: inline-block;
  410. }
  411. .batch .el-button {
  412. padding: 9px 15px !important;
  413. }
  414. .el-table th>.cell {
  415. color: #333;
  416. font-weight: bold;
  417. font-size: 14px;
  418. }
  419. .el-table__footer-wrapper,
  420. .el-table__header-wrapper {
  421. border-bottom: 1.4px solid #D6D6D6;
  422. }
  423. .el-table .el-button {
  424. padding: 0 !important;
  425. border: 0;
  426. margin: 0 5px;
  427. }
  428. #app .copy .el-input-group__append {
  429. background-color: #409EFF;
  430. border-color: #409EFF;
  431. padding: 0 10px;
  432. }
  433. #app .table-body .copybtn {
  434. color: #fff;
  435. padding: 0 30px;
  436. }
  437. .el-alert {
  438. padding: 0;
  439. padding-left: 5px;
  440. padding-bottom: 5px;
  441. }
  442. .el-alert--info .el-alert__description {
  443. color: #606266;
  444. }
  445. .el-alert .el-button {
  446. margin-left: 20px;
  447. }
  448. .el-alert__content {
  449. display: flex;
  450. align-items: center;
  451. }
  452. .table-body .el-alert__title {
  453. margin-top: 5px;
  454. font-weight: 400;
  455. }
  456. .el-table th>.cell {
  457. color: #333;
  458. font-weight: bold;
  459. font-size: 14px;
  460. }
  461. .el-table__footer-wrapper,
  462. .el-table__header-wrapper {
  463. border-bottom: 1.4px solid #D6D6D6;
  464. }
  465. .item-box {
  466. margin-right: 20px;
  467. }
  468. .flex {
  469. display: flex;
  470. align-items: center;
  471. }
  472. .input-title {
  473. margin-right: 15px;
  474. }
  475. .item-box .label {
  476. margin-right: 8px;
  477. }
  478. .com-share-pop {
  479. display: inline-block;
  480. }
  481. .stat-item {
  482. margin: 10px 0px;
  483. padding-left: 7px;
  484. color: #A2A2A2;
  485. }
  486. .stat-item>span {
  487. margin: 0px 10px;
  488. }
  489. .user_img{
  490. position: relative;
  491. margin-right: 8px;
  492. /* height: 50px;
  493. width: 50px; */
  494. }
  495. .default-avatar{
  496. width: 50px;
  497. height: 50px;
  498. border-radius: 50%;
  499. margin-right: 8px;
  500. }
  501. .uer-nickname {
  502. flex: 1;
  503. }
  504. </style>