entrySecurityCheck.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <!-- 入户安全检查项 -->
  3. <div>
  4. <actionBar menuTitle="入户安全检查项" :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm"
  5. @openModel="openModel" @searchProtocol="searchProtocol">
  6. </actionBar>
  7. <tables :suspension="false" :tableList="tableList" :tableData="tableData" @buttonData="buttonData"></tables>
  8. <!-- 分页 -->
  9. <div class="paging_bottom" v-if="Total">
  10. <pagination :total="Total" :currentPage="Pagination.PageIndex" @changeSize="changeSize"
  11. @changeCurrent="changeCurrent">
  12. </pagination>
  13. </div>
  14. <el-dialog :title="staffTitle" :visible.sync="staffDialogVisible" width="800px" :close-on-click-modal="false"
  15. @close="closeDialog">
  16. <forms ref="childRules" :formNewList="formRuleList" :ruleForm="ruleForm" labelWidth="100px"></forms>
  17. <span slot="footer" class="dialog-footer">
  18. <el-button plain @click="staffDialogVisible = false">取 消</el-button>
  19. <el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
  20. </span>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. import {
  26. getInspectExpand,
  27. addInspectExpand,
  28. putInspectExpand,
  29. delInspectExpand
  30. } from '@/api/securityCheck'
  31. import actionBar from '@/components/actionBar'
  32. import tables from '@/components/tables'
  33. import pagination from '@/components/pagination'
  34. import forms from '@/components/forms'
  35. import {
  36. formRules,
  37. employee
  38. } from "./checkEntry.js";
  39. export default {
  40. components: {
  41. actionBar,
  42. tables,
  43. pagination,
  44. forms
  45. },
  46. data() {
  47. return {
  48. staffTitle: '添加',
  49. staffDialogVisible: false,
  50. Pagination: {
  51. PageIndex: 1,
  52. PageSize: 10,
  53. },
  54. operateList: [{
  55. type: 'add',
  56. title: '添加',
  57. icon: 'el-icon-plus',
  58. }],
  59. formList: [{
  60. type: 'input',
  61. label: '检查项',
  62. field: 'inspectExplain',
  63. placeholder: '检查项',
  64. }],
  65. searchRuleForm: {
  66. inspectExplain: '',
  67. },
  68. tableList: employee(),
  69. tableData: [],
  70. Total: 0,
  71. formRuleList: [],
  72. ruleForm: {
  73. inspectExplain: '',
  74. },
  75. enterpriseId: null,
  76. operationType: '',
  77. confirmLoading: false,
  78. }
  79. },
  80. mounted() {
  81. const dataList = formRules();
  82. this.formRuleList = dataList;
  83. this.getList()
  84. },
  85. methods: {
  86. // 搜索
  87. searchProtocol(value) {
  88. this.searchValue = value
  89. this.getList()
  90. },
  91. openModel(type) {
  92. this.operationType = type
  93. if (type == 'add') {
  94. this.staffTitle = '添加'
  95. }
  96. this.staffDialogVisible = true
  97. },
  98. // 获取入户安全检查列表
  99. getList() {
  100. var params = {
  101. page: this.Pagination.PageIndex,
  102. pageSize: this.Pagination.PageSize,
  103. ...this.searchValue
  104. }
  105. getInspectExpand(params).then(res => {
  106. if (res.code == 200) {
  107. this.tableData = res.data.list
  108. this.Total = res.data.count
  109. }
  110. })
  111. },
  112. handleAdd() {
  113. let flag = this.$refs['childRules'].validateForm();
  114. if (flag) {
  115. this.confirmLoading = true
  116. if (this.operationType == 'add') {
  117. var params = {
  118. ...this.ruleForm
  119. }
  120. addInspectExpand(params).then(res => {
  121. if (res.code == 200) {
  122. this.$message({
  123. message: '操作成功',
  124. type: 'success'
  125. });
  126. this.getList()
  127. }
  128. this.staffDialogVisible = false
  129. this.confirmLoading = false
  130. }).catch(() => {
  131. this.confirmLoading = false
  132. })
  133. } else if (this.operationType == 'edit') {
  134. this.editItem()
  135. }
  136. } else {
  137. this.$message.error('表单信息不完整,请继续填写完整');
  138. }
  139. },
  140. editItem() {
  141. var params = {
  142. id: this.enterpriseId,
  143. ...this.ruleForm
  144. }
  145. params.price = Number(params.price)
  146. putInspectExpand(params).then(res => {
  147. if (res.code == 200) {
  148. this.$message({
  149. message: '操作成功',
  150. type: 'success'
  151. });
  152. this.getList()
  153. }
  154. this.staffDialogVisible = false
  155. this.confirmLoading = false
  156. }).catch(() => {
  157. this.confirmLoading = false
  158. })
  159. },
  160. // 删除
  161. deleteItem(id) {
  162. this.$confirm('此操作将永久删除该检查项, 是否继续?', '提示', {
  163. confirmButtonText: '确定',
  164. cancelButtonText: '取消',
  165. type: 'warning'
  166. }).then(() => {
  167. delInspectExpand({
  168. id: id,
  169. }).then(res => {
  170. if (res.code == 200) {
  171. this.$message({
  172. message: '操作成功',
  173. type: 'success'
  174. });
  175. this.getList()
  176. }
  177. })
  178. }).catch(() => {});
  179. },
  180. buttonData(row, type) {
  181. this.enterpriseId = row.id
  182. this.operationType = type
  183. if (type == 'edit') {
  184. this.staffDialogVisible = true
  185. this.staffTitle = '编辑'
  186. this.$nextTick(() => {
  187. this.ruleForm.inspectExplain = row.inspectExplain
  188. })
  189. } else if (type == 'del') {
  190. this.deleteItem(row.id)
  191. }
  192. },
  193. changeSize(val) {
  194. this.Pagination.PageSize = val
  195. this.getList()
  196. },
  197. changeCurrent(val) {
  198. this.Pagination.PageIndex = val
  199. this.getList()
  200. },
  201. // 清空表单
  202. closeDialog() {
  203. this.$refs.childRules.resetCheck();
  204. }
  205. },
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. </style>