index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="page">
  3. <template-page v-if="!formDialog" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="200"
  4. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  5. :operation="operation()">
  6. </template-page>
  7. <div class="detail" v-else>
  8. <detail :id="id" @back="backList" :formType="formDialogType" :title="'工程维保' + formDialogTitles[formDialogType]"></detail>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import TemplatePage from '@/components/template/template-page-1.vue'
  14. import import_mixin from '@/components/template/import_mixin.js'
  15. import ImageUpload from '@/components/file-upload'
  16. import detail from './detail.vue'
  17. import operation_mixin from '@/components/template/operation_mixin.js'
  18. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  19. import { listPageV2,pageExport, getDetail, save } from "@/api/engineeringMaintenance/basicData";
  20. export default {
  21. components: { TemplatePage, ImageUpload, detail },
  22. mixins: [import_mixin, operation_mixin],
  23. data() {
  24. return {
  25. // 表格属性
  26. tableAttributes: {
  27. // 启用勾选列
  28. selectColumn: false
  29. },
  30. // 表格事件
  31. tableEvents: {
  32. 'selection-change': this.selectionChange
  33. },
  34. // 勾选选中行
  35. recordSelected: [],
  36. /** 表单变量 */
  37. formDialogType: 0,
  38. formDialogTitles: ["新增","编辑", "详情"],
  39. formDialog: false,
  40. formData: {
  41. },
  42. id: ''
  43. }
  44. },
  45. computed: {
  46. // 更多参数
  47. moreParameters() {
  48. return []
  49. },
  50. // 事件组合
  51. optionsEvensGroup() {
  52. return [
  53. [
  54. [
  55. this.optionsEvensAuth("add", {
  56. click: () => {
  57. this.addData()
  58. }
  59. })
  60. ],
  61. ]
  62. ]
  63. },
  64. formItems() {
  65. }
  66. },
  67. methods: {
  68. // 列表请求函数
  69. getList: listPageV2,
  70. // 列表导出函数
  71. exportList: pageExport,
  72. backList() {
  73. this.id = ''
  74. this.formDialog = false;
  75. this.$nextTick(()=>{
  76. this.$refs.pageRef.refreshList()
  77. })
  78. },
  79. // 表格列解析渲染数据更改
  80. columnParsing(item, defaultData) {
  81. if (item.jname === 'serviceCode') {
  82.         defaultData.render = (h, { row, index, column }) => {
  83.           return (
  84.             <div style="cursor: pointer;display: flex">
  85.               {row.serviceCode ? row.serviceCode.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="cover" style="width:80px;height:80px;" />) : null}
  86.             </div>
  87.           )
  88.         }
  89.       }
  90. return defaultData
  91. },
  92. // 监听勾选变化
  93. selectionChange(data) {
  94. this.recordSelected = data
  95. },
  96. // 表格操作列
  97. operation() {
  98. return this.operationBtn({
  99. edit: {
  100. btnType: 'text',
  101. click: ({ row, index, column }) => {
  102. this.id = row.id
  103. this.formDialogType = 1
  104. this.openForm()
  105. }
  106. },
  107. detail: {
  108. btnType: 'text',
  109. click: ({ row, index, column }) => {
  110. this.id = row.id
  111. this.formDialogType = 2
  112. this.openForm()
  113. }
  114. },
  115. expenseApply: {
  116. btnType: 'text',
  117. click: ({ row, index, column }) => {
  118. this.$router.push({
  119. name: row.isAllFee=='YES'?"allInclusiveExpense":'applicationWithoutFee',
  120. query: {
  121. rpProjectRepairId:row.id
  122. }
  123. })
  124. }
  125. },
  126. serviceOrderDetail: {
  127. btnType: 'text',
  128. click: ({ row, index, column }) => {
  129. this.$router.push({
  130. name: "workOrderPool",
  131. query: {
  132. rpProjectRepairId:row.id
  133. }
  134. })
  135. }
  136. }
  137. })
  138. },
  139. addData() {
  140. this.formDialogType = 0
  141. this.openForm()
  142. },
  143. openForm() {
  144. this.formDialog = true;
  145. },
  146. formCancel() {
  147. this.$refs.formRef.$refs.inlineForm.clearValidate()
  148. this.$data.formData = this.$options.data().formData
  149. this.formDialog = false
  150. },
  151. formConfirm() {
  152. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  153. if (valid) {
  154. (save)({
  155. ...this.formData,
  156. imgUrl:this.formData.imgUrl.map(item=>item.url).join(",")
  157. }).then(res => {
  158. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  159. this.formCancel()
  160. this.$refs.pageRef.refreshList()
  161. })
  162. }
  163. })
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. .tab{
  170. padding: 20px 20px 0 20px;
  171. }
  172. .page{
  173. height: 100%;
  174. }
  175. </style>