EvaluationPlan.vue 8.0 KB

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