index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <template-page
  3. v-if="pageShow"
  4. ref="pageRef"
  5. :get-list="getList"
  6. :exportList="exportList"
  7. :table-attributes="tableAttributes"
  8. :table-events="tableEvents"
  9. :options-evens-group="optionsEvensGroup"
  10. :moreParameters="moreParameters"
  11. :column-parsing="columnParsing"
  12. :operation="operation()"
  13. key="pageType"
  14. >
  15. <div class="cartographer_big">
  16. <el-dialog title="考核项目" width="100%" :modal="false" :visible.sync="formDialog" :before-close="handleClose">
  17. <zj-page-container>
  18. <zj-page-fill>
  19. <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
  20. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  21. <zj-form-module title="设置" label-width="100px" :form-data="formData" :form-items="formItems">
  22. </zj-form-module>
  23. </zj-form-container>
  24. </div>
  25. </zj-page-fill>
  26. <div style="text-align: right; box-sizing: border-box; padding: 16px 20px">
  27. <el-button size="mini" @click="handleClose">取消</el-button>
  28. <el-button size="mini" type="primary" @click="save">保存</el-button>
  29. </div>
  30. </zj-page-container>
  31. </el-dialog>
  32. </div>
  33. </template-page>
  34. </template>
  35. <script>
  36. import TemplatePage from '@/components/template/template-page-1.vue'
  37. import import_mixin from '@/components/template/import_mixin.js'
  38. import operation_mixin from '@/components/template/operation_mixin.js'
  39. import {
  40. letterManagerListProject,
  41. letterManagerListProjectExport,
  42. letterManagerImportProject,
  43. letterManagerAddProject,
  44. letterManagerUpdateProject,
  45. letterManagerDetailProject,
  46. letterManagerDelProject
  47. } from '@/api/assessmentItemSetting.js'
  48. import { required } from '@/components/template/rules_verify.js'
  49. import { commonTemplateDownload } from '@/api/common.js'
  50. export default {
  51. components: { TemplatePage },
  52. mixins: [import_mixin, operation_mixin],
  53. data() {
  54. return {
  55. pageType: 'list',
  56. pageShow: true,
  57. // 表格属性
  58. tableAttributes: {
  59. // 启用勾选列
  60. selectColumn: false
  61. },
  62. // 表格事件
  63. tableEvents: {
  64. 'selection-change': this.selectionChange
  65. },
  66. // 勾选选中行
  67. recordSelected: [],
  68. /** 表单变量 */
  69. formDialog: false,
  70. formData: {
  71. fraction: '',
  72. price: '',
  73. projectId: '',
  74. projectName: '',
  75. projectReg: '',
  76. projectText: '',
  77. status: ''
  78. }
  79. }
  80. },
  81. computed: {
  82. // 事件组合
  83. optionsEvensGroup() {
  84. return [
  85. [
  86. [
  87. this.optionsEvensAuth('add', {
  88. click: this.openForm
  89. })
  90. ]
  91. ],
  92. [
  93. [
  94. this.optionsEvensAuth('import', ({ moduleName }) => {
  95. return {
  96. name: moduleName,
  97. render: () => {
  98. return this.importButton(letterManagerImportProject, moduleName)
  99. }
  100. }
  101. })
  102. ],
  103. [
  104. this.optionsEvensAuth('downloadTemplate', {
  105. click: () => {
  106. commonTemplateDownload({ name: '违规项目导入模板.xlsx' }, `违规项目导入模板`)
  107. .then(res => {
  108. this.$message({
  109. message: '下载成功',
  110. type: 'success'
  111. })
  112. })
  113. .catch(err => {
  114. this.$message.error('下载失败')
  115. })
  116. }
  117. })
  118. ]
  119. ]
  120. ]
  121. },
  122. // 更多参数
  123. moreParameters() {
  124. return []
  125. },
  126. formItems() {
  127. return [
  128. {
  129. md: 12,
  130. name: 'el-input',
  131. attributes: {},
  132. formItemAttributes: {
  133. label: '考核项目',
  134. prop: 'projectName',
  135. rules: [...required]
  136. }
  137. },
  138. {
  139. md: 12,
  140. name: 'el-input',
  141. attributes: {
  142. 'show-word-limit': true,
  143. maxlength: 100
  144. },
  145. formItemAttributes: {
  146. label: '考核条例',
  147. prop: 'projectReg',
  148. rules: [...required]
  149. }
  150. },
  151. {
  152. md: 24,
  153. name: 'el-input',
  154. attributes: { type: 'textarea', rows: 3, 'show-word-limit': true, maxlength: 500 },
  155. formItemAttributes: {
  156. label: '考核规定',
  157. prop: 'projectText',
  158. rules: [...required]
  159. }
  160. },
  161. {
  162. md: 8,
  163. name: 'el-input',
  164. attributes: {},
  165. formItemAttributes: {
  166. label: '考核金额',
  167. prop: 'price',
  168. rules: [...required]
  169. }
  170. },
  171. {
  172. md: 8,
  173. name: 'el-input',
  174. attributes: {},
  175. formItemAttributes: {
  176. label: '考核分数',
  177. prop: 'fraction',
  178. rules: [...required]
  179. }
  180. },
  181. {
  182. name: 'el-radio',
  183. options: [
  184. { label: '启用', value: 'ON' },
  185. { label: '禁用', value: 'OFF' }
  186. ],
  187. md: 6,
  188. attributes: {
  189. placeholder: '请输入'
  190. },
  191. formItemAttributes: {
  192. label: '状态',
  193. prop: 'status',
  194. rules: [...required]
  195. }
  196. }
  197. ]
  198. }
  199. },
  200. methods: {
  201. // 列表请求函数
  202. getList: letterManagerListProject,
  203. // 列表导出函数
  204. exportList: letterManagerListProjectExport,
  205. // 表格列解析渲染数据更改
  206. columnParsing(item, defaultData) {
  207. return defaultData
  208. },
  209. // 监听勾选变化
  210. selectionChange(data) {
  211. this.recordSelected = data
  212. },
  213. // 打开创建弹窗
  214. openForm() {
  215. this.formDialog = true
  216. },
  217. // 打开详情弹窗
  218. openDetailForm(row) {
  219. Promise.all([letterManagerDetailProject({ id: row.projectId })]).then(([res1, res2]) => {
  220. this.formData = { ...res1.data }
  221. this.formDialog = true
  222. })
  223. },
  224. handleClose() {
  225. this.$refs?.formRef?.resetFields()
  226. this.$data.formData = this.$options.data().formData
  227. this.formDialog = false
  228. },
  229. // 操作按钮
  230. operation() {
  231. return this.operationBtn({
  232. edit: {
  233. click: ({ row, index, column }) => {
  234. this.openDetailForm(row)
  235. }
  236. },
  237. del: {
  238. conditions: ({ row, index, column }) => {
  239. return true
  240. },
  241. prompt: '确定删除?',
  242. click: ({ row, index, column }) => {
  243. letterManagerDelProject({
  244. id: row.projectId
  245. })
  246. .then(res => {
  247. this.$refs.pageRef.refreshList()
  248. this.$message({
  249. type: 'success',
  250. message: `删除成功!`
  251. })
  252. })
  253. .catch(err => {
  254. console.log(err)
  255. })
  256. }
  257. }
  258. })
  259. },
  260. // 保存
  261. save() {
  262. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  263. if (valid) {
  264. ;(this.formData?.projectId ? letterManagerUpdateProject : letterManagerAddProject)(this.formData).then(
  265. res => {
  266. this.$message({
  267. type: 'success',
  268. message: '保存成功'
  269. })
  270. this.handleClose()
  271. this.$refs.pageRef.refreshList()
  272. }
  273. )
  274. }
  275. })
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped></style>