branchManager.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class='m-container'>
  3. <h2>
  4. <div class="squrt"></div>合作单位
  5. </h2>
  6. <div class="m-core">
  7. <div @click="openTeaching('create')"
  8. class='newBand'>新建</div>
  9. <!-- 搜索类型 -->
  10. <!-- <el-form :inline="true"
  11. class="searchForm"
  12. v-model="searchForm">
  13. <el-form-item>
  14. <el-select v-model="searchForm.status"
  15. placeholder="工作类型">
  16. <el-option label="哈哈哈"
  17. value="1"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-input suffix-icon="el-icon-search"
  22. placeholder="请输入搜索内容"></el-input>
  23. </el-form-item>
  24. </el-form>
  25. <div class="searchWrap">
  26. <p>查询条件:</p>
  27. <div class="searchItem"
  28. @click="closeSearch(item)"
  29. v-for="(item,index) in searchLsit">
  30. {{ item.key }}
  31. <i class="el-icon-close"></i>
  32. </div>
  33. </div> -->
  34. <!-- 列表 -->
  35. <div class="tableWrap">
  36. <el-table :data='tableList'
  37. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  38. <el-table-column align='center'
  39. prop='id'
  40. label="单位编号">
  41. </el-table-column>
  42. <el-table-column align='center'
  43. prop='name'
  44. label="单位名称">
  45. </el-table-column>
  46. <el-table-column align='center'
  47. prop='linkman'
  48. label="联系人">
  49. </el-table-column>
  50. <el-table-column align='center'
  51. prop='job'
  52. label="职位">
  53. </el-table-column>
  54. <el-table-column align='center'
  55. prop='mobileNo'
  56. label="手机号">
  57. </el-table-column>
  58. <!-- <el-table-column align='center' prop='ownershipType'
  59. label="权属类型">
  60. <template slot-scope="scope">
  61. {{ scope.row.ownershipType | branchType }}
  62. </template>
  63. </el-table-column> -->
  64. <el-table-column align='center'
  65. label="操作"
  66. width='100'>
  67. <template slot-scope="scope">
  68. <el-button @click="openTeaching('update', scope.row)"
  69. type="text">修改</el-button>
  70. <el-button @click="onDelete(scope.row)"
  71. type="text">删除</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <pagination :total="pageInfo.total"
  76. :page.sync="pageInfo.page"
  77. :limit.sync="pageInfo.limit"
  78. :page-sizes="pageInfo.page_size"
  79. @pagination="getList" />
  80. </div>
  81. </div>
  82. <el-dialog :title="formTitle[formActionTitle]"
  83. :visible.sync="teachingStatus"
  84. @close="onFormClose('ruleForm')"
  85. width="500px">
  86. <el-form :model="form"
  87. :rules="rules"
  88. ref="ruleForm">
  89. <el-form-item label="单位名称"
  90. prop="name"
  91. :label-width="formLabelWidth">
  92. <el-input v-model="form.name"
  93. autocomplete="off"></el-input>
  94. </el-form-item>
  95. <el-form-item label="联系人"
  96. prop="linkman"
  97. :label-width="formLabelWidth">
  98. <el-input v-model="form.linkman"
  99. autocomplete="off"></el-input>
  100. </el-form-item>
  101. <el-form-item label="职位"
  102. prop="job"
  103. :label-width="formLabelWidth">
  104. <el-input v-model="form.job"
  105. autocomplete="off"></el-input>
  106. </el-form-item>
  107. <el-form-item label="手机号"
  108. prop="mobileNo"
  109. :label-width="formLabelWidth">
  110. <el-input v-model="form.mobileNo"
  111. autocomplete="off"></el-input>
  112. </el-form-item>
  113. <!-- <el-form-item label="权属类型" prop="ownershipType" :label-width="formLabelWidth">
  114. <el-select v-model="form.ownershipType">
  115. <el-option label="自有" value="OWN"></el-option>
  116. <el-option label="合作" value="COOPERATION"></el-option>
  117. <el-option label="租赁" value="LEASE"></el-option>
  118. </el-select>
  119. </el-form-item> -->
  120. </el-form>
  121. <span slot="footer"
  122. class="dialog-footer">
  123. <el-button @click="teachingStatus = false">取 消</el-button>
  124. <el-button type="primary"
  125. @click="onTeachingSubmit('ruleForm')">确 定</el-button>
  126. </span>
  127. </el-dialog>
  128. </div>
  129. </template>
  130. <script>
  131. import pagination from '@/components/Pagination/index'
  132. import { cooperationOrganAdd, cooperationOrganUpdate, cooperationOrganDel, queryPage } from '@/api/systemManage'
  133. import store from '@/store'
  134. import { isvalidPhone } from '@/utils/validate'
  135. let validPhone = (rule, value, callback) => {
  136. if (!value) {
  137. callback(new Error('请输入电话号码'))
  138. } else if (!isvalidPhone(value)) {
  139. callback(new Error('请输入正确的11位手机号码'))
  140. } else {
  141. callback()
  142. }
  143. }
  144. export default {
  145. components: { pagination },
  146. name: 'adminManager',
  147. data () {
  148. return {
  149. searchForm: {
  150. status: ''
  151. },
  152. searchLsit: [],
  153. tableList: [],
  154. pageInfo: {
  155. // 分页规则
  156. limit: 10, // 限制显示条数
  157. page: 1, // 当前页
  158. total: 0, // 总条数
  159. page_size: [10, 20, 40, 50] // 选择限制显示条数
  160. },
  161. teachingStatus: false, // 添加教学点
  162. formActionTitle: 'create',
  163. formTitle: {
  164. create: '添加合作单位',
  165. update: '修改合作单位'
  166. },
  167. formLabelWidth: '100px',
  168. form: {
  169. id: null,
  170. name: null, // 教学点名称
  171. linkman: null, // 来源
  172. job: null, // 费用
  173. mobileNo: null,
  174. // ownershipType: null,
  175. organId: null
  176. },
  177. rules: {
  178. name: [{ required: true, message: '请输入教学点名称', trigger: 'blur' }],
  179. linkman: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  180. job: [{ required: true, message: '请输入职位', trigger: 'blur' }],
  181. mobileNo: [{ required: true, validator: validPhone, trigger: 'blur' }],
  182. // ownershipType: [{ required: true, message: '请选择权属类型', trigger: 'change' }]
  183. },
  184. }
  185. },
  186. mounted () {
  187. this.getList() // 获取列表数据
  188. },
  189. methods: {
  190. onDelete (rows) {
  191. this.$confirm('您确定删除合作单位?', '提示', {
  192. confirmButtonText: '确定',
  193. cancelButtonText: '取消',
  194. type: 'warning'
  195. }).then(() => {
  196. cooperationOrganDel(rows.id).then(res => {
  197. if (res.code == 200) {
  198. this.$message.success('删除成功')
  199. this.teachingStatus = false
  200. this.getList()
  201. } else {
  202. this.$message.error(res.msg)
  203. }
  204. })
  205. }).catch(() => { });
  206. },
  207. onTeachingSubmit (formName) { // 添加数据
  208. this.$refs[formName].validate((valid) => {
  209. if (valid) {
  210. if (this.formActionTitle == 'create') {
  211. cooperationOrganAdd(this.form).then(res => {
  212. if (res.code == 200) {
  213. this.$message.success('修改成功')
  214. this.teachingStatus = false
  215. this.getList()
  216. } else {
  217. this.$message.error(res.msg)
  218. }
  219. })
  220. } else if (this.formActionTitle == 'update') {
  221. cooperationOrganUpdate(this.form).then(res => {
  222. // console.log(res)
  223. if (res.code == 200) {
  224. this.$message.success('修改成功')
  225. this.teachingStatus = false
  226. this.getList()
  227. } else {
  228. this.$message.error(res.msg)
  229. }
  230. })
  231. }
  232. } else {
  233. return false;
  234. }
  235. })
  236. },
  237. getList () {
  238. queryPage({
  239. search: this.form.organId,
  240. rows: this.pageInfo.limit,
  241. page: this.pageInfo.page
  242. }).then(res => {
  243. if (res.code == 200 && res.data) {
  244. this.tableList = res.data.rows
  245. this.pageInfo.total = res.data.total
  246. }
  247. })
  248. },
  249. openTeaching (type, rows) {
  250. // 重置数据
  251. this.form = {
  252. id: null,
  253. name: null, // 教学点名称
  254. linkman: null, // 来源
  255. job: null, // 费用
  256. mobileNo: null, // 合作单位
  257. ownershipType: null,
  258. organId: null
  259. }
  260. this.teachingStatus = true
  261. this.formActionTitle = type
  262. // 修改的时候赋值
  263. if (type == 'update') {
  264. this.form = {
  265. id: rows.id,
  266. name: rows.name, // 教学点名称
  267. linkman: rows.linkman, // 来源
  268. job: rows.job, // 费用
  269. mobileNo: rows.mobileNo ? rows.mobileNo : null,
  270. ownershipType: rows.ownershipType,
  271. organId: null
  272. }
  273. }
  274. },
  275. onFormClose (formName) { // 关闭弹窗重置验证
  276. this.$refs[formName].clearValidate()
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss">
  282. .el-button--primary {
  283. background: #14928a;
  284. border-color: #14928a;
  285. color: #fff;
  286. &:hover,
  287. &:active,
  288. &:focus {
  289. background: #14928a;
  290. border-color: #14928a;
  291. color: #fff;
  292. }
  293. }
  294. .el-vue-search-box-container {
  295. position: absolute !important;
  296. left: 10px;
  297. margin-top: 10px;
  298. z-index: 99999 !important;
  299. }
  300. </style>