group.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div>
  3. <el-row class="handle-box" style="margin-bottom: 10px">
  4. <el-col :span="24">
  5. <el-input v-model="search.name" class="ch-input ch-input-size" placeholder="分公司名称" size="small" @keyup.enter.native="handleSearch()" />
  6. <el-button class="ch-button-warning" size="small" @click="handleReset()"><i class="el-icon-search" />&nbsp;重置</el-button>
  7. <el-button class="ch-button" size="small" @click="handleSearch()"><i class="el-icon-search" />&nbsp;搜索</el-button>
  8. <el-button class="ch-button-export" size="small" @click="confirmOutput()"><i class="el-icon-download" />&nbsp;导出</el-button>
  9. <el-button class="ch-button" size="small" style="float: right;margin-top: 4px" @click="handleAdd()"><i class="el-icon-menu" />&nbsp;新增</el-button>
  10. </el-col>
  11. </el-row>
  12. <el-row class="handle-box">
  13. <el-col :span="24">
  14. <el-table v-loading="loading" :data="AllData" row-class-name="g_table_row" stripe>
  15. <el-table-column type="index" width="60" />
  16. <el-table-column label="组织机构" prop="name" />
  17. <el-table-column label="编码" prop="code" />
  18. <el-table-column label="顺序号" prop="sequenceNo" />
  19. <el-table-column label="说明" prop="comments" />
  20. <el-table-column header-align="center" label="操作" width="180">
  21. <template scope="scope">
  22. <el-button size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
  23. <el-button size="mini" type="danger" @click="handleDel(scope.row)">删除</el-button>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <div class="table-page">
  28. <el-pagination
  29. :current-page.sync="currentPage"
  30. :page-size="pageSize"
  31. :total="allpage"
  32. background
  33. layout="total, prev, pager, next"
  34. @current-change="handleCurrentChange"
  35. />
  36. </div>
  37. </el-col>
  38. </el-row>
  39. <el-dialog :title="dialogTitle" class="statistic_base" :visible.sync="dialogVisible" top="50px" width="75%" append-to-body @open="dlgOpen">
  40. <el-form ref="form" :model="form" :rules="rules" style="width: 100%;padding: 5px">
  41. <el-row>
  42. <el-col style="padding-bottom: 10px">
  43. <el-card shadow="always" style="padding: 15px 5px 5px 15px">
  44. <el-row>
  45. <el-col :span="3" class="col-txt"><span>组织机构</span></el-col>
  46. <el-col :span="20" class="col-input">
  47. <el-form-item>
  48. <el-input v-model="form.name" />
  49. </el-form-item>
  50. </el-col>
  51. </el-row>
  52. <el-row>
  53. <el-col :span="3" class="col-txt"><span>编码</span></el-col>
  54. <el-col :span="20" class="col-input">
  55. <el-form-item>
  56. <el-input v-model="form.code" />
  57. </el-form-item>
  58. </el-col>
  59. </el-row>
  60. <el-row>
  61. <el-col :span="3" class="col-txt"><span>顺序号</span></el-col>
  62. <el-col :span="20" class="col-input">
  63. <el-form-item>
  64. <el-input v-model="form.sequenceNo" />
  65. </el-form-item>
  66. </el-col>
  67. </el-row>
  68. <el-row>
  69. <el-col :span="3" class="col-txt"><span>说明</span></el-col>
  70. <el-col :span="20" class="col-input">
  71. <el-form-item>
  72. <el-input v-model="form.comments" />
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. </el-card>
  77. </el-col>
  78. </el-row>
  79. </el-form>
  80. <div slot="footer">
  81. <el-button @click="dialogVisible = false">取 消</el-button>
  82. <el-button type="primary" @click="confirmSubmit()">确 定</el-button>
  83. </div>
  84. </el-dialog>
  85. </div>
  86. </template>
  87. <script>
  88. import Base from '@/views/base/base'
  89. import BaseData from '@/views/base/baseData'
  90. export default {
  91. name: 'Group',
  92. mixins: [Base, BaseData],
  93. data() {
  94. return {
  95. dc_key: [],
  96. // 列表相关
  97. search: {
  98. name: ''
  99. },
  100. AllData: [],
  101. loading: false,
  102. // 弹框相关
  103. dialogVisible: false,
  104. dialogTitle: '新增',
  105. isAdd: true,
  106. form: this.initForm(),
  107. rules: {}
  108. }
  109. },
  110. mounted() {
  111. this.getData()
  112. },
  113. methods: {
  114. getData: function() {
  115. const _this = this
  116. _this.loading = true
  117. _this.AllData = []
  118. this.search.pageNum = this.currentPage
  119. this.search.pageSize = this.pageSize
  120. this.baseRequest('list', this.search).then((res) => {
  121. if (res.data.rows) {
  122. res.data.rows.forEach(function(item) {
  123. const json = _this.getItemJson(item)
  124. _this.AllData.push(json)
  125. })
  126. _this.allpage = res.data.total
  127. }
  128. _this.loading = false
  129. }).catch(() => {
  130. })
  131. this.initOutData()
  132. },
  133. handleSearch: function() {
  134. this.getData()
  135. },
  136. handleReset: function() {
  137. for (const i in this.search) {
  138. if (i !== 'pageNum' && i !== 'pageSize') {
  139. this.search[i] = ''
  140. }
  141. }
  142. this.handleSearch()
  143. },
  144. initOutData: function() {
  145. const _this = this
  146. this.OutData = []
  147. const title = [' 组织机构', ' 编码', ' 顺序号', ' 说明']
  148. this.OutData.push(title)
  149. this.baseRequest('listAll', this.search).then((res) => {
  150. if (res.data) {
  151. res.data.forEach(function(item) {
  152. const jsonMap = _this.getItemJson(item)
  153. const jsonArray = []
  154. jsonArray.push(jsonMap.name)
  155. jsonArray.push(jsonMap.code)
  156. jsonArray.push(jsonMap.sequenceNo)
  157. jsonArray.push(jsonMap.comments)
  158. _this.OutData.push(jsonArray)
  159. })
  160. }
  161. }).catch(() => {
  162. })
  163. },
  164. getItemJson: function(item) {
  165. return item
  166. },
  167. initForm: function() {
  168. return {
  169. id: '',
  170. name: '',
  171. comments: '',
  172. code: '',
  173. sequenceNo: ''
  174. }
  175. },
  176. confirmOutput() {
  177. const OutSize = [{ wch: 15 }, { wch: 15 }, { wch: 15 }]
  178. const fileName = 'group导出' + new Date().Format('yyyyMMddhhmm')
  179. this.$outputXlsxFile(this.OutData, OutSize, fileName)
  180. },
  181. dlgOpen: function() {
  182. const _this = this
  183. if (_this.form.id !== '') {
  184. const postData = {
  185. id: _this.form.id
  186. }
  187. this.baseRequest('getById', postData).then((res) => {
  188. if (res.data) {
  189. _this.form = Object.assign({}, _this.form, res.data)
  190. }
  191. }).catch(() => {
  192. })
  193. }
  194. },
  195. /* 编辑*/
  196. handleEdit: function(val) {
  197. this.isAdd = false
  198. this.form.id = val.id
  199. this.dialogVisible = true
  200. this.dialogTitle = '编辑'
  201. },
  202. /* 新增*/
  203. handleAdd: function() {
  204. this.form = this.initForm()
  205. this.isAdd = true
  206. this.dialogVisible = true
  207. this.dialogTitle = '新增'
  208. },
  209. confirmSubmit: function() {
  210. const _this = this
  211. this.$refs.form.validate(valid => {
  212. if (valid) {
  213. let soaUrl = 'edit'
  214. const extraData = {}
  215. const postData = Object.assign({}, _this.form, extraData)
  216. if (this.isAdd) {
  217. soaUrl = 'add'
  218. }
  219. this.opRecord(postData, soaUrl)
  220. } else {
  221. // console.log('error submit!!')
  222. return false
  223. }
  224. })
  225. },
  226. baseRequest(opUrl, postData) {
  227. return this.$channel.globeRequest('SysGroupController', opUrl, postData, 'project')
  228. }
  229. }
  230. }
  231. </script>
  232. <style scoped>
  233. .ch-input .el-input__inner {
  234. border-color: #32323A;
  235. }
  236. .ch-input-size {
  237. width: 150px;
  238. }
  239. .ch-button {
  240. border-color: #32323A;
  241. background-color: #32323A;
  242. color: #fff;
  243. }
  244. .ch-button-warning {
  245. margin-left: 10px;
  246. border-color: #E6A23C;
  247. background-color: #E6A23C;
  248. color: #fff;
  249. }
  250. .ch-button-export {
  251. margin-left: 10px;
  252. border-color: #98CC1F;
  253. background-color: #98CC1F;
  254. color: #fff;
  255. }
  256. /deep/.el-dialog__header {
  257. padding: 10px 20px;
  258. }
  259. /deep/.el-dialog__body {
  260. padding: 10px 20px;
  261. }
  262. </style>