positionInfo.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!--
  2. * @Description: create
  3. * @Version: 1.0
  4. * @Autor: XuTongZhang
  5. * @Date: 2020-07-28 17:19:43
  6. * @LastEditors: XuTongZhang
  7. * @LastEditTime: 2020-08-12 17:05:48
  8. -->
  9. <template>
  10. <div class="indexPage">
  11. <v-input :btn="btn" :list="list" @add="add"></v-input>
  12. <v-table
  13. :table="table"
  14. :tableList="tableList"
  15. :sortType="true"
  16. :queryData="queryData"
  17. @details="details"
  18. @editor="editor"
  19. @del="del"
  20. ></v-table>
  21. <v-pager @page="callPage" :total="totalrecords"></v-pager>
  22. <el-dialog width="600px" :visible.sync="dialogFormVisible" :before-close="close" :close-on-click-modal="false">
  23. <el-form :model="form" ref="form" label-width="140px" :rules="rules" label-position="left">
  24. <el-form-item label="职位名称" prop="positionName">
  25. <el-input v-if="state!==2" v-model="form.positionName" placeholder="请输入职位名称" autocomplete="off"></el-input>
  26. <div v-else>{{form.positionName}}</div>
  27. </el-form-item>
  28. <el-form-item label="职位描述" prop="positionIntroduce">
  29. <el-input
  30. v-if="state!==2"
  31. type="textarea"
  32. :rows="4"
  33. resize="none"
  34. placeholder="请输入内容"
  35. v-model="form.positionIntroduce"
  36. ></el-input>
  37. <div v-else>{{form.positionIntroduce}}</div>
  38. </el-form-item>
  39. <el-form-item label="职位状态" prop="isDisable">
  40. <el-radio-group v-if="state!==2" v-model="form.isDisable">
  41. <el-radio :label="0">启用</el-radio>
  42. <el-radio :label="1">禁用</el-radio>
  43. </el-radio-group>
  44. <div v-else>{{['启用', '禁用'][form.isDisable]}}</div>
  45. </el-form-item>
  46. </el-form>
  47. <div slot="footer" class="dialog-footer">
  48. <el-button @click="close">取 消</el-button>
  49. <el-button type="primary" v-if="state!==2" @click="determine">确 定</el-button>
  50. </div>
  51. </el-dialog>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. data () {
  57. return {
  58. tableList: [],
  59. dialogFormVisible: false,
  60. page: 1,
  61. form: {
  62. positionName: '',
  63. positionIntroduce: '',
  64. isDisable: 0
  65. },
  66. totalrecords: 0,
  67. state: 0,
  68. pickList: [],
  69. rules: {
  70. positionName: [{ required: true, message: '请填写职位名称', trigger: 'change' }],
  71. positionIntroduce: [{ required: true, message: '请填写职位描述', trigger: 'change' }],
  72. isDisable: [{ required: true, message: '请选择职位状态', trigger: 'change' }]
  73. },
  74. list: [],
  75. btn: [
  76. {
  77. name: '添加',
  78. type: 'success',
  79. method: 'add'
  80. }
  81. ],
  82. table: {
  83. column: [
  84. {
  85. label: '编号',
  86. props: 'companyId'
  87. },
  88. {
  89. label: '职位名称',
  90. props: 'positionName'
  91. },
  92. {
  93. label: '职位描述',
  94. props: 'positionIntroduce'
  95. },
  96. {
  97. label: '职位状态',
  98. props: 'isDisable',
  99. options: ['有效', '禁用']
  100. }
  101. ],
  102. handle: [
  103. {
  104. title: '查看',
  105. method: 'details',
  106. type: 'info'
  107. },
  108. {
  109. title: '编辑',
  110. method: 'editor',
  111. type: 'warning'
  112. },
  113. {
  114. title: '删除',
  115. method: 'del',
  116. type: 'danger'
  117. }
  118. ]
  119. }
  120. }
  121. },
  122. created () {
  123. this.queryData()
  124. },
  125. methods: {
  126. queryData (form = {}) {
  127. let page = this.page
  128. let reqdata = {}
  129. this.$api
  130. .post('/position/queryPositionList', {
  131. reqdata,
  132. page
  133. })
  134. .then((res) => {
  135. this.totalrecords = res.totalrecords
  136. this.tableList = res.list
  137. })
  138. },
  139. add () {
  140. this.open()
  141. this.info = {}
  142. this.state = 0
  143. },
  144. getDetails (row) {
  145. let reqdata = { id: row.id }
  146. this.$api
  147. .post('/position/queryPositionDetail', {
  148. reqdata
  149. })
  150. .then((res) => {
  151. this.open()
  152. this.form = res.object
  153. })
  154. },
  155. details (row) {
  156. this.getDetails(row)
  157. this.state = 2
  158. },
  159. editor (row) {
  160. this.getDetails(row)
  161. this.state = 1
  162. },
  163. del (row) {
  164. this.$api
  165. .post('/position/deletePosition', {
  166. reqdata: { id: row.id }
  167. })
  168. .then((res) => {
  169. this.queryData()
  170. })
  171. },
  172. determine () {
  173. let a
  174. this.$refs['form'].validate((valid) => {
  175. a = valid
  176. })
  177. if (!a) return
  178. let url = this.state ? '/position/updatePosition' : '/position/savePosition'
  179. let reqdata = this.form
  180. this.$api
  181. .post(url, {
  182. reqdata
  183. })
  184. .then((res) => {
  185. this.close()
  186. this.queryData()
  187. })
  188. },
  189. open () {
  190. this.dialogFormVisible = true
  191. },
  192. close () {
  193. this.dialogFormVisible = false
  194. this.form = {
  195. positionName: '',
  196. positionIntroduce: '',
  197. isDisable: 0
  198. }
  199. },
  200. callPage (val) {
  201. this.page = val
  202. this.queryData()
  203. }
  204. },
  205. watch: {
  206. dialogFormVisible: function (val, oldVla) {
  207. if (this.state === 2) {
  208. if (this.$refs['form'] !== undefined) {
  209. this.$refs['form'].resetFields()
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .dialog-footer {
  218. display: flex;
  219. justify-content: center;
  220. align-items: center;
  221. }
  222. </style>