mockPractice.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!-- 模拟练习 -->
  2. <template>
  3. <div class="app-container mockPractice">
  4. <div class="page-container mockPracticePage" v-if="pageType === 1">
  5. <div class="page-form-title-box">
  6. <el-form :model="queryParams" class="form-box" ref="queryForm"
  7. :inline="true" style="width:100%;"
  8. >
  9. <el-form-item label="" prop="queryParamsData1">
  10. <el-input
  11. maxLength="30"
  12. v-model="queryParams.queryParamsData1"
  13. placeholder="请输入"
  14. style="width: 200px"
  15. />
  16. </el-form-item>
  17. <el-form-item label="" prop="queryParamsData2">
  18. <el-select v-model="queryParams.queryParamsData2" placeholder="请选择" style="width: 200px">
  19. <el-option
  20. v-for="dict in optionList"
  21. :key="dict.value"
  22. :label="dict.label"
  23. :value="dict.value"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="" prop="state">
  28. <el-date-picker
  29. :clearable="false"
  30. v-model="dateRange"
  31. size="small"
  32. style="width: 240px"
  33. value-format="yyyy-MM-dd"
  34. type="daterange"
  35. range-separator="-"
  36. start-placeholder="开始日期"
  37. end-placeholder="结束日期"
  38. ></el-date-picker>
  39. </el-form-item>
  40. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  41. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  42. <p class="page-submit-common-style-button"
  43. style="float: right;"
  44. @click="tableButton(1)"
  45. v-hasPermiRouter="['demo:demo:add']"
  46. >新增</p>
  47. </el-form>
  48. </div>
  49. <div class="page-content-box">
  50. <el-table class="table-box" border :data="dataList">
  51. <el-table-column label="名称" prop="name" show-overflow-tooltip/>
  52. <el-table-column label="内容" prop="content" width="200" show-overflow-tooltip/>
  53. <el-table-column label="状态" prop="state" width="100" show-overflow-tooltip>
  54. <template slot-scope="scope">
  55. <el-switch
  56. @click.native="tableButton(5,scope.row)"
  57. class="switch captcha-img"
  58. :active-value="true"
  59. :inactive-value="false"
  60. active-color="#0183FA"
  61. inactive-color="#999"
  62. v-model="scope.row.state"
  63. active-text="启用"
  64. inactive-text="停用"
  65. disabled
  66. ></el-switch>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="创建时间" prop="createTime" width="200" show-overflow-tooltip>
  70. <template slot-scope="scope">
  71. <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}") }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  75. <template slot-scope="scope">
  76. <div class="table-button-box">
  77. <p class="table-button-null"></p>
  78. <p class="table-button-p"
  79. @click="tableButton(2,scope.row)"
  80. v-hasPermiRouter="['demo:demo:detail']"
  81. >详情</p>
  82. <p class="table-button-p"
  83. @click="tableButton(3,scope.row)"
  84. v-hasPermiRouter="['demo:demo:edit']"
  85. >编辑</p>
  86. <p class="table-button-p"
  87. @click="tableButton(4,scope.row)"
  88. v-hasPermiRouter="['demo:demo:del']"
  89. >删除</p>
  90. <p class="table-button-null"></p>
  91. </div>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <pagination :page-sizes="[20, 30, 40, 50]"
  96. v-show="total>0"
  97. :total="total"
  98. :page.sync="queryParams.page"
  99. :limit.sync="queryParams.pageSize"
  100. @pagination="getList"
  101. />
  102. </div>
  103. </div>
  104. <!--<add-page :propsData="propsData" v-if="pageType === 2"></add-page>-->
  105. </div>
  106. </template>
  107. <script>
  108. //import { getDicts } from "@/api/commonality/noPermission";
  109. //import { systemUserSelect } from "@/api/commonality/permission";
  110. //import { getInfo } from "@/api/basicsModules/index";
  111. //import addPage from "./addPage.vue";
  112. export default {
  113. name: 'index',
  114. //components: {
  115. // addPage
  116. //},
  117. data() {
  118. return {
  119. tableButtonType: this.hasPermiDom(['demo:demo:detail', 'demo:demo:edit', 'demo:demo:del']),
  120. //页面状态
  121. pageType: 1,
  122. //下拉列表数据
  123. optionList: [{ value: true, label: '启用' }, { value: false, label: '停用' }],
  124. //查询条件
  125. queryParams: {
  126. page: 1,
  127. pageSize: 20,
  128. queryParamsData1: '',
  129. queryParamsData2: null
  130. },
  131. //时间数据
  132. dateRange: [],
  133. //列表数据
  134. dataList: [],
  135. //数据数量
  136. total: 0,
  137. //组件传参
  138. propsData: {}
  139. }
  140. },
  141. created() {
  142. },
  143. mounted() {
  144. //this.getList();
  145. },
  146. methods: {
  147. //查询按钮
  148. handleQuery() {
  149. this.$set(this.queryParams, 'page', 1)
  150. this.getList()
  151. },
  152. //重置按钮
  153. resetQuery() {
  154. this.$set(this, 'dateRange', [])
  155. this.$set(this, 'queryParams', {
  156. page: 1,
  157. pageSize: 20,
  158. queryParamsData1: '',
  159. queryParamsData2: null
  160. })
  161. this.getList()
  162. },
  163. //获取数据列表
  164. getList() {
  165. let obj = JSON.parse(JSON.stringify(this.queryParams))
  166. if (this.dateRange[0]) {
  167. obj.startTime = this.dateRange[0] + 'T00:00:00'
  168. obj.endTime = this.dateRange[1] + 'T23:59:59'
  169. } else {
  170. obj.startTime = ''
  171. obj.endTime = ''
  172. }
  173. getListFunction(obj).then(response => {
  174. this.$set(this, 'dataList', response.data.records)
  175. this.$set(this, 'total', response.data.total)
  176. })
  177. },
  178. //操作按钮
  179. tableButton(type, row) {
  180. let self = this
  181. if (type == 1) {
  182. //新增
  183. this.$set(this, 'pageType', 2)
  184. this.$set(this, 'propsData', {})
  185. } else if (type == 2) {
  186. //详情
  187. this.$set(this, 'pageType', 2)
  188. let obj = JSON.parse(JSON.stringify(row))
  189. obj.showType = true
  190. this.$set(this, 'propsData', obj)
  191. } else if (type == 3) {
  192. //编辑
  193. this.$set(this, 'pageType', 2)
  194. let obj = JSON.parse(JSON.stringify(row))
  195. obj.showType = false
  196. this.$set(this, 'propsData', obj)
  197. } else if (type == 4) {
  198. //删除
  199. this.$confirm('是否确认删除?', '提示', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消',
  202. type: 'warning'
  203. }).then(function() {
  204. }).then(() => {
  205. deleteFunction({ id: row.id }).then(response => {
  206. self.msgSuccess(response.message)
  207. self.getList()
  208. })
  209. }).catch(() => {
  210. })
  211. } else if (type == 5) {
  212. //启用&停用
  213. let text = row.state ? '停用' : '启用'
  214. this.$confirm('是否确认' + text + '?', '提示', {
  215. confirmButtonText: '确定',
  216. cancelButtonText: '取消',
  217. type: 'warning'
  218. }).then(function() {
  219. }).then(() => {
  220. stateFunction({ id: row.id, state: !row.state }).then(response => {
  221. self.msgSuccess(response.message)
  222. self.getList()
  223. })
  224. }).catch(() => {
  225. })
  226. } else if (type == 6) {
  227. //返回并刷新
  228. this.$set(this, 'pageType', 1)
  229. this.getList()
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style scoped lang="scss">
  236. .mockPractice {
  237. .mockPracticePage {
  238. }
  239. }
  240. </style>