Rap 原分销系统代码Web
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

0b4869538c9359be1deabd1686e390e612fb9970.svn-base 9.5KB

5 месяцев назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="app-container">
  3. <div style="margin-bottom:10px">
  4. <el-button type="success" @click="addBtn">新增</el-button>
  5. </div>
  6. <!--搜索-->
  7. <el-form class="mt_15" ref="form" inline size="small">
  8. <el-form-item label="公司名称">
  9. <el-input v-model.trim="searchParm.name" clearable placeholder='名称'></el-input>
  10. </el-form-item>
  11. <el-form-item label="地址">
  12. <el-input v-model.trim="searchParm.address" clearable></el-input>
  13. </el-form-item>
  14. <el-form-item label="联系方式">
  15. <el-input v-model.trim="searchParm.phone" clearable></el-input>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-button type="primary" @click="goSearch">搜索</el-button>
  19. <el-button type="warning" @click="resetForm">重置</el-button>
  20. </el-form-item>
  21. </el-form>
  22. <!--表格渲染-->
  23. <el-table ref="table" border size="small" :data="list" :header-cell-style="{textAlign:'center'}" :cell-style="{textAlign:'center'}">
  24. <el-table-column label="序号" type="index" width="50" />
  25. <el-table-column label="公司名称" prop="name" />
  26. <el-table-column label="地址" prop="address" />
  27. <el-table-column label="联系方式" prop="phone" />
  28. <el-table-column label="创建时间" prop="createdAt" />
  29. <el-table-column label="修改时间" prop="updatedAt" />
  30. <el-table-column label="操作" width="220">
  31. <template slot-scope="scope">
  32. <el-button type="info" @click="getBtnById(scope.row.id)">查看</el-button>
  33. <el-button type="warning" @click="editById(scope.row)">修改</el-button>
  34. <el-button type="danger" @click="delById(scope.row.id)">删除</el-button>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. <!--分页-->
  39. <div class="mt_15">
  40. <el-pagination
  41. @size-change="handleSizeChange"
  42. @current-change="handleCurrentChange"
  43. :current-page="searchParm.page"
  44. :page-sizes="[10, 20, 30, 40, 50]"
  45. :page-size="searchParm.pageSize"
  46. layout="total, sizes, prev, pager, next, jumper"
  47. :total="total">
  48. </el-pagination>
  49. </div>
  50. <!--新增弹窗-->
  51. <el-dialog :visible.sync="dialogAddVisible" :title="dialogAddTitle" center width="45%">
  52. <div class="dialog-content">
  53. <el-form ref="addParm" size="small" :model="addParm" :rules="rules" label-width="100px">
  54. <el-form-item label="公司名称" prop="name">
  55. <el-input v-model.trim="addParm.name" clearable></el-input>
  56. </el-form-item>
  57. <el-form-item label="地址" prop="address">
  58. <el-input v-model.trim="addParm.address" clearable></el-input>
  59. </el-form-item>
  60. <el-form-item label="联系方式" prop="phone">
  61. <el-input v-model.trim="addParm.phone" clearable></el-input>
  62. </el-form-item>
  63. </el-form>
  64. </div>
  65. <span slot="footer">
  66. <el-button type="info" @click="sureAddCancle('addParm')">取消</el-button>
  67. <el-button type="primary" @click="sureAdd('addParm')">确认</el-button>
  68. </span>
  69. </el-dialog>
  70. <!--修改弹窗-->
  71. <el-dialog :visible.sync="dialogEditVisible" :title="dialogEditTitle" center width="45%">
  72. <div class="dialog-content">
  73. <el-form ref="editParm" size="small" :model="editParm" :rules="rules" label-width="100px">
  74. <el-form-item label="公司名称" prop="name">
  75. <el-input v-model.trim="editParm.name" clearable></el-input>
  76. </el-form-item>
  77. <el-form-item label="地址" prop="address">
  78. <el-input v-model.trim="editParm.address" clearable></el-input>
  79. </el-form-item>
  80. <el-form-item label="联系方式" prop="phone">
  81. <el-input v-model.trim="editParm.phone" clearable></el-input>
  82. </el-form-item>
  83. </el-form>
  84. </div>
  85. <span slot="footer">
  86. <el-button type="info" @click="sureEditCancle('editParm')">取消</el-button>
  87. <el-button type="primary" @click="sureEdit('editParm')">确认</el-button>
  88. </span>
  89. </el-dialog>
  90. <!--详情弹窗-->
  91. <el-dialog :visible.sync="dialogDetailVisible" :title="dialogDetailTitle" center width="45%">
  92. <div class="dialog-content">
  93. <el-form ref="form" size="small" label-width="100px">
  94. <el-form-item label="公司名称" prop="name" >
  95. <el-input v-model.trim="detailParm.name" :disabled="true"></el-input>
  96. </el-form-item>
  97. <el-form-item label="地址" prop="address">
  98. <el-input v-model.trim="detailParm.address" :disabled="true"></el-input>
  99. </el-form-item>
  100. <el-form-item label="联系方式" prop="phone">
  101. <el-input v-model.trim="detailParm.phone" :disabled="true"></el-input>
  102. </el-form-item>
  103. </el-form>
  104. </div>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. import { add, editById, delById, getList, getById, getAll } from '@/api/group/company'
  110. export default {
  111. // 数据
  112. data() {
  113. return {
  114. searchParm: {
  115. page: 1,
  116. pageSize: 10,
  117. name:null,
  118. sort:'created_at',
  119. order:'desc',
  120. address:null,
  121. phone:null,
  122. },
  123. total:0,
  124. list: [],
  125. dialogAddVisible: false,
  126. dialogAddTitle: '新增',
  127. dialogDetailVisible: false,
  128. dialogDetailTitle: '详情',
  129. dialogEditVisible: false,
  130. dialogEditTitle: '修改',
  131. addParm: {
  132. id: null,
  133. name:'',
  134. address:'',
  135. phone: '',
  136. },
  137. detailParm: {
  138. id: null,
  139. name:'',
  140. address:'',
  141. phone: '',
  142. },
  143. editParm: {
  144. id: null,
  145. name:'',
  146. address:'',
  147. phone: '',
  148. },
  149. rules: {
  150. platformId: [
  151. { required: true, message: '请输入平台ID', trigger: 'blur' }
  152. ],
  153. platformName: [
  154. { required: true, message: '请输入平台名称', trigger: 'blur' }
  155. ],
  156. name: [
  157. { required: true, message: '请输入公司名称', trigger: 'blur' }
  158. ],
  159. address: [
  160. { required: true, message: '请输入地址', trigger: 'blur' }
  161. ],
  162. phone: [
  163. { required: true, message: '请输入联系方式', trigger: 'blur' },
  164. { pattern : /^[+]?(0|([1-9]\d*))?$/, message : '请输入正确的手机号码', trigger: 'blur'}
  165. ]
  166. }
  167. }
  168. },
  169. // 调用
  170. created() {
  171. this.goSearch()
  172. },
  173. //方法
  174. methods: {
  175. resetForm() {
  176. this.searchParm.name = null;
  177. this.searchParm.address = null;
  178. this.searchParm.phone = null;
  179. this.goSearch()
  180. },
  181. // 查询
  182. goSearch() {
  183. this.searchParm.page=1
  184. this.getDataList()
  185. },
  186. //重置
  187. // 新增
  188. addBtn(){
  189. this.addParm = {
  190. id: null,
  191. platformName:'',
  192. name:'',
  193. address:'',
  194. phone: '',
  195. }
  196. this.dialogAddTitle='新增'
  197. this.dialogAddVisible = true;
  198. this.$refs.addParm.clearValidate();
  199. },
  200. // 根据id删除
  201. delById(id){
  202. this.$confirm('确认删除?','提示',{
  203. confirmButtonText: '确定',
  204. cancelButtonText: '取消',
  205. type: 'warning'
  206. }).then(() => {
  207. delById({id}).then(res => {
  208. if(res.code==200) {
  209. this.$message.success('删除成功!')
  210. this.getDataList()
  211. }
  212. }).catch(err => {
  213. console.log(err)
  214. })
  215. }).catch(() => {
  216. this.$message.info('取消删除')
  217. })
  218. },
  219. // 修改
  220. editById(data){
  221. this.$refs.editParm.clearValidate();
  222. getById({id: data.id}).then(res => {
  223. if(res.code==200) {
  224. this.editParm.id = res.data.id;
  225. this.editParm.name = res.data.name;
  226. this.editParm.address = res.data.address;
  227. this.editParm.phone = res.data.phone;
  228. this.dialogEditVisible = true
  229. }
  230. }).catch(err => {
  231. console.log(err)
  232. })
  233. },
  234. // 确认修改
  235. sureEdit(editParm){
  236. this.$refs[editParm].validate((valid) => {
  237. if (valid) {
  238. this.$refs.editParm.clearValidate();
  239. editById(this.editParm).then(res => {
  240. if(res.code==200) {
  241. console.log(res)
  242. this.dialogEditVisible = false
  243. this.$message.success('修改成功!')
  244. this.getDataList()
  245. }
  246. }).catch(err => {
  247. console.log(err)
  248. })
  249. } else {
  250. console.log('error submit!!');
  251. return false;
  252. }
  253. });
  254. },
  255. sureEditCancle(editParm){
  256. this.dialogEditVisible=flase
  257. this.$refs.editParm.clearValidate();
  258. },
  259. // 确认新增
  260. sureAdd(addParm){
  261. this.$refs[addParm].validate((valid) => {
  262. if (valid) {
  263. this.$refs.addParm.clearValidate();
  264. add(this.addParm).then(res => {
  265. if(res.code==200) {
  266. this.dialogAddVisible = false
  267. this.$message.success('新增成功!')
  268. this.getDataList()
  269. }
  270. }).catch(err => {
  271. console.log(err)
  272. })
  273. } else {
  274. console.log('error submit!!');
  275. return false;
  276. }
  277. });
  278. },
  279. sureAddCancle(addParm){
  280. this.dialogAddVisible=flase
  281. this.$refs.addParm.clearValidate();
  282. },
  283. // 查看根据id
  284. getBtnById(id){
  285. getById({id}).then(res => {
  286. if(res.code==200) {
  287. this.detailParm.id = res.data.id;
  288. this.detailParm.name = res.data.name;
  289. this.detailParm.address = res.data.address;
  290. this.detailParm.phone = res.data.phone;
  291. this.dialogDetailVisible = true
  292. this.$refs.ruleForm.clearValidate()
  293. }
  294. }).catch(err => {
  295. console.log(err)
  296. })
  297. },
  298. // 分页获取表格数据
  299. getDataList(){
  300. getList(this.searchParm).then(res => {
  301. console.log(res)
  302. if(res.code==200) {
  303. console.log(res)
  304. this.list = res.data.list;
  305. this.total = res.data.total;
  306. }
  307. }).catch(err => {
  308. console.log(err)
  309. })
  310. },
  311. // 分页
  312. handleSizeChange(val) {
  313. console.log(`每页 ${val} 条`);
  314. this.searchParm.pageSize = val;
  315. this.getDataList();
  316. },
  317. handleCurrentChange(val) {
  318. console.log(`当前页: ${val}`);
  319. this.searchParm.page = val;
  320. this.getDataList();
  321. }
  322. }
  323. }
  324. </script>
  325. <style rel="stylesheet/scss" lang="scss" scoped>
  326. </style>