index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="page">
  3. <template-page v-if="!formDialog" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="150"
  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. if (item.jname === 'startTime') {
  91.         defaultData.render = (h, { row, index, column }) => {
  92.           return (
  93.             <div style="cursor: pointer;display: flex">
  94.               {row.startTime.substring(0,10)}
  95.             </div>
  96.           )
  97.         }
  98.  }
  99. if (item.jname === 'endTime') {
  100.         defaultData.render = (h, { row, index, column }) => {
  101.           return (
  102.             <div style="cursor: pointer;display: flex">
  103.               {row.endTime.substring(0,10)}
  104.             </div>
  105.           )
  106.         }
  107.  }
  108. return defaultData
  109. },
  110. // 监听勾选变化
  111. selectionChange(data) {
  112. this.recordSelected = data
  113. },
  114. // 表格操作列
  115. operation() {
  116. return this.operationBtn({
  117. edit: {
  118. btnType: 'text',
  119. click: ({ row, index, column }) => {
  120. this.id = row.id
  121. this.formDialogType = 1
  122. this.openForm()
  123. }
  124. },
  125. detail: {
  126. btnType: 'text',
  127. click: ({ row, index, column }) => {
  128. this.id = row.id
  129. this.formDialogType = 2
  130. this.openForm()
  131. }
  132. },
  133. // expenseApply: {
  134. // btnType: 'text',
  135. // click: ({ row, index, column }) => {
  136. // this.$router.push({
  137. // name: row.isAllFee=='YES'?"allInclusiveExpense":'applicationWithoutFee',
  138. // query: {
  139. // rpProjectRepairId:row.id
  140. // }
  141. // })
  142. // }
  143. // },
  144. serviceOrderDetail: {
  145. btnType: 'text',
  146. click: ({ row, index, column }) => {
  147. this.$router.push({
  148. name: "workOrderPool",
  149. query: {
  150. rpProjectRepairId:row.id
  151. }
  152. })
  153. }
  154. }
  155. })
  156. },
  157. addData() {
  158. this.formDialogType = 0
  159. this.openForm()
  160. },
  161. openForm() {
  162. this.formDialog = true;
  163. },
  164. formCancel() {
  165. this.$refs.formRef.$refs.inlineForm.clearValidate()
  166. this.$data.formData = this.$options.data().formData
  167. this.formDialog = false
  168. },
  169. formConfirm() {
  170. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  171. if (valid) {
  172. (save)({
  173. ...this.formData,
  174. imgUrl:this.formData.imgUrl.map(item=>item.url).join(",")
  175. }).then(res => {
  176. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  177. this.formCancel()
  178. this.$refs.pageRef.refreshList()
  179. })
  180. }
  181. })
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .tab{
  188. padding: 20px 20px 0 20px;
  189. }
  190. .page{
  191. height: 100%;
  192. }
  193. </style>