index.vue 5.7 KB

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