EvaluationPlan.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :span="6">
  7. <a-form-item label="方案名称">
  8. <a-input id="evaluationPlan-name" allowClear v-model.trim="queryParam.name" placeholder="请输入企业名称" />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :span="6">
  12. <a-form-item label="启用状态">
  13. <v-select
  14. id="evaluationPlan-status"
  15. ref="status"
  16. allowClear
  17. placeholder="状态"
  18. v-model="queryParam.status"
  19. code="ENABLE_FLAG"></v-select>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="6">
  23. <a-button id="evaluationPlan-search" type="primary" style="margin-right: 10px;" @click="$refs.table.refresh(true)">查询</a-button>
  24. <a-button id="evaluationPlan-reset" type="" @click="reset">重置</a-button>
  25. </a-col>
  26. </a-row>
  27. </a-form>
  28. </div>
  29. <a-divider />
  30. <a-row class="add-btn" type="flex" justify="space-between">
  31. <a-button id="evaluationPlan-add" type="primary" icon="plus" @click="openModal">新增</a-button>
  32. <a-col id="evaluationPlan-setDefaultPlan" @click="handleDefaultSet">
  33. <a-icon type="setting" class="setting-icon" />
  34. <span class="setting">默认方案设置</span>
  35. </a-col>
  36. </a-row>
  37. <s-table
  38. ref="table"
  39. size="default"
  40. :rowKey="(record) => record.id"
  41. :columns="columns"
  42. :data="loadData"
  43. bordered>
  44. <!-- 操作 -->
  45. <template slot="action" slot-scope="text, record">
  46. <a-icon id="evaluationPlan-edit" type="edit" class="actionBtn blue" v-if="record.status == '0'" @click="openModal(record)" />
  47. <a-icon id="evaluationPlan-delete" type="delete" class="actionBtn red" v-if="record.status == '0'" @click="delect(record)" />
  48. <a-icon id="evaluationPlan-setting" type="setting" class="actionBtn orange" @click="handleSet(record)" />
  49. </template>
  50. <!-- 启用禁用 -->
  51. <template slot="enable" slot-scope="text, row">
  52. <a-switch id="evaluationPlan-enableStatus" checkedChildren="启用" unCheckedChildren="禁用" v-model="row.status" @change="changeFlagHandle(row)" />
  53. </template>
  54. </s-table>
  55. <!-- 新增/编辑 弹窗 -->
  56. <add-evaModal :itemId="itemId" :visible="openAddModal" @refresh="$refs.table.refresh()" @close="openAddModal=false"></add-evaModal>
  57. <!-- 选择考评项弹窗 -->
  58. <set-evaModal :itemId="itemId" :itemName="itemName" :visible="openSetting" @close="openSetting=false"></set-evaModal>
  59. <!-- 设置默认方案弹窗 -->
  60. <set-evaDefaultModal :itemId="itemId" :defaultPlanList="defaultPlanList" :visible="openDefaultSetting" @refresh="getDefaultPlan" @close="openDefaultSetting=false"></set-evaDefaultModal>
  61. </a-card>
  62. </template>
  63. <script>
  64. import {
  65. STable,
  66. VSelect
  67. } from '@/components'
  68. import {
  69. planQueryByPage,
  70. planEnable,
  71. planDefaultQuery,
  72. planDelete
  73. } from '@/api/evaluationPlan.js'
  74. import addEvaModal from './AddEvaModal.vue'
  75. import setEvaModal from './SetEvaModal.vue'
  76. import setEvaDefaultModal from './SetEvaDefaultModal.vue'
  77. export default {
  78. name: 'EvaluationPlanList',
  79. components: {
  80. STable,
  81. VSelect,
  82. addEvaModal,
  83. setEvaModal,
  84. setEvaDefaultModal
  85. },
  86. data () {
  87. return {
  88. pageNo: 1,
  89. pageSize: 10,
  90. openAddModal: false, // 打开新增弹窗
  91. openSetting: false, // 打开选择考评项弹窗
  92. openDefaultSetting: false, // 打开设置默认方案弹窗
  93. itemId: '', // 要编辑的方案id
  94. itemName: '', // 方案名称
  95. defaultPlanList: [], // 默认方案列表
  96. // 查询参数
  97. queryParam: {
  98. name: '',
  99. status: '' // 状态
  100. },
  101. // 表头
  102. columns: [{
  103. title: '序号',
  104. dataIndex: 'no',
  105. width: '40',
  106. align: 'center'
  107. },
  108. {
  109. title: '考评方案名称',
  110. dataIndex: 'name',
  111. align: 'center'
  112. },
  113. {
  114. title: '考评方案说明',
  115. dataIndex: 'desc',
  116. width: '120',
  117. align: 'center'
  118. },
  119. {
  120. title: '适用模式',
  121. width: '120',
  122. align: 'center',
  123. dataIndex: 'scopeTypeDictValue'
  124. },
  125. {
  126. title: '状态',
  127. width: '250',
  128. align: 'center',
  129. dataIndex: 'status',
  130. scopedSlots: {
  131. customRender: 'enable'
  132. }
  133. },
  134. {
  135. title: '操作',
  136. width: '200',
  137. align: 'center',
  138. scopedSlots: {
  139. customRender: 'action'
  140. }
  141. }
  142. ],
  143. // 加载数据方法 必须为 Promise 对象
  144. loadData: parameter => {
  145. return planQueryByPage(Object.assign(parameter, this.queryParam)).then(res => {
  146. if (res.status == 200) {
  147. const no = (res.data.pageNo - 1) * res.data.pageSize
  148. for (let i = 0; i < res.data.list.length; i++) {
  149. const _item = res.data.list[i]
  150. _item.no = no + i + 1
  151. _item.status = _item.status + '' === '1'
  152. }
  153. return res.data
  154. }
  155. })
  156. }
  157. }
  158. },
  159. beforeRouteEnter (to, from, next) {
  160. next(vm => {
  161. vm.reset()
  162. vm.getDefaultPlan()
  163. })
  164. },
  165. methods: {
  166. // 默认方案查询
  167. getDefaultPlan () {
  168. planDefaultQuery().then(res => {
  169. // console.log(res, 'rrrrrrrr')
  170. if (res.status == 200) {
  171. this.defaultPlanList = res.data
  172. } else {
  173. this.defaultPlanList = []
  174. }
  175. })
  176. },
  177. // 修改状态
  178. changeFlagHandle (record) {
  179. const _data = {
  180. id: record.id,
  181. status: record.status ? '1' : '0'
  182. }
  183. planEnable(_data).then(res => {
  184. console.log(res.status)
  185. if (res.status == '200') {
  186. this.$message.success('修改成功')
  187. this.$refs.table.refresh()
  188. } else {
  189. record.status = !record.status
  190. }
  191. })
  192. },
  193. // 打开新增弹窗
  194. openModal (row) {
  195. this.itemId = row ? row.id : ''
  196. this.openAddModal = true
  197. },
  198. // 打开默认方案设置弹窗
  199. handleDefaultSet () {
  200. this.openDefaultSetting = true
  201. },
  202. // 删除
  203. delect (row) {
  204. const _this = this
  205. // 判断当前方案是否为默认方案
  206. const has = this.defaultPlanList.find(item => item.assessId == row.id)
  207. if (has) {
  208. this.$warning({
  209. title: '警告',
  210. content: '该考评方案为当前默认考评方案,不能删除,请取消该方案的默认后再进行删除!'
  211. })
  212. } else {
  213. this.$confirm({
  214. title: '警告',
  215. content: '删除后原数据不可恢复,是否删除?',
  216. okText: '确定',
  217. cancelText: '取消',
  218. onOk () {
  219. planDelete({
  220. id: row.id
  221. }).then(res => {
  222. if (res.status == 200) {
  223. _this.$message.success(res.message)
  224. _this.$refs.table.refresh()
  225. }
  226. })
  227. }
  228. })
  229. }
  230. },
  231. // 打开设置弹框
  232. handleSet (row) {
  233. this.itemId = row.id
  234. this.itemName = row.name
  235. this.openSetting = true
  236. console.log(this.openSetting)
  237. },
  238. // 重置
  239. reset () {
  240. this.queryParam = {
  241. name: '',
  242. status: '' // 状态
  243. }
  244. this.$refs.table.refresh(true)
  245. }
  246. }
  247. }
  248. </script>
  249. <style scoped>
  250. .table-page-search-wrapper,
  251. .addButton {
  252. margin-bottom: 0;
  253. }
  254. .table-page-search-wrapper .ant-form-inline .ant-form-item {
  255. margin-bottom: 10px;
  256. }
  257. .add-btn {
  258. margin-bottom: 10px;
  259. }
  260. .actionBtn {
  261. font-size: 20px;
  262. padding: 0 10px;
  263. }
  264. .setting-icon {
  265. font-size: 20px;
  266. margin-right: 5px;
  267. color: #1890FF;
  268. }
  269. .setting {
  270. font-size: 16px;
  271. color: #1890FF;
  272. border-bottom: 1px solid #1890FF;
  273. cursor: pointer;
  274. }
  275. .blue {
  276. color: #1890FF;
  277. }
  278. .green {
  279. color: #16b50e;
  280. }
  281. .red {
  282. color: red;
  283. }
  284. .orange {
  285. color: #ffaa00;
  286. }
  287. </style>