index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="80"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation()">
  5. <el-dialog title="" width="500px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
  6. :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
  7. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  8. <zj-form-module :title="formDialogTitles[formDialogType]" label-width="100px" :showPackUp="false"
  9. :form-data="formData" :form-items="formItems" :disabled="formDialogType==2">
  10. </zj-form-module>
  11. </zj-form-container>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button size="mini" @click="formCancel">取 消</el-button>
  14. <el-button size="mini" v-if="formDialogType !== 2" type="primary" @click="formConfirm()">确定</el-button>
  15. </div>
  16. </el-dialog>
  17. </template-page>
  18. </template>
  19. <script>
  20. import TemplatePage from '@/components/template/template-page-1.vue'
  21. import import_mixin from '@/components/template/import_mixin.js'
  22. import ImageUpload from '@/components/file-upload'
  23. import operation_mixin from '@/components/template/operation_mixin.js'
  24. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  25. import { listPageV2,pageExport, getDetail, save } from "@/api/workOrder/basicData";
  26. export default {
  27. components: { TemplatePage, ImageUpload },
  28. mixins: [import_mixin, operation_mixin],
  29. data() {
  30. return {
  31. // 事件组合
  32. optionsEvensGroup: [
  33. [
  34. [
  35. {
  36. name: '新建',
  37. click: this.addData
  38. }
  39. ],
  40. ],
  41. ],
  42. // 表格属性
  43. tableAttributes: {
  44. // 启用勾选列
  45. selectColumn: false
  46. },
  47. // 表格事件
  48. tableEvents: {
  49. 'selection-change': this.selectionChange
  50. },
  51. // 勾选选中行
  52. recordSelected: [],
  53. /** 表单变量 */
  54. formDialogType: 0,
  55. formDialogTitles: ["新增","编辑", "详情"],
  56. formDialog: false,
  57. formData: {
  58. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  59. orderSmallTypeText: '',
  60. orderType: '',
  61. status: true,
  62. sortNum: '',
  63. imgUrl: []
  64. }
  65. }
  66. },
  67. computed: {
  68. // 更多参数
  69. moreParameters() {
  70. return []
  71. },
  72. // 事件组合
  73. optionsEvensGroup() {
  74. return [
  75. [
  76. [
  77. this.optionsEvensAuth("add", {
  78. click: () => {
  79. }
  80. })
  81. ],
  82. ]
  83. ]
  84. },
  85. formItems() {
  86. return [{
  87. md: 24,
  88. isShow: true,
  89. name: 'el-input',
  90. attributes: { placeholder: '请输入', disabled: true },
  91. formItemAttributes: {
  92. label: '所属商户',
  93. prop: 'companyName',
  94. rules: [...required]
  95. },
  96. }, {
  97. md: 24,
  98. isShow: true,
  99. name: 'el-select',
  100. options: [{label: '安装',value: 'INSTALL'},{label: '维修',value: 'REPAIR'}],
  101. attributes: { placeholder: '请选择' },
  102. formItemAttributes: {
  103. label: '所属业务线',
  104. prop: 'orderType',
  105. rules: [...required]
  106. },
  107. }, {
  108. md: 24,
  109. isShow: true,
  110. name: 'el-input',
  111. attributes: { placeholder: '请输入工单类型', },
  112. formItemAttributes: {
  113. label: '工单类型',
  114. prop: 'orderSmallTypeText',
  115. rules: [...required]
  116. }
  117. },{
  118. md: 24,
  119. isShow: true,
  120. name: 'slot-component',
  121. attributes: { },
  122. formItemAttributes: {
  123. label: '状态',
  124. prop: 'status',
  125. rules: [...required]
  126. },
  127. render: (h, { props, onInput }) => {
  128. var { value } = props
  129. return (
  130. <el-radio-group v-model={this.formData.status}>
  131. <el-radio disabled={this.formDialogType==2} label={true}>启用</el-radio>
  132. <el-radio disabled={this.formDialogType==2} label={false}>禁用</el-radio>
  133. </el-radio-group>
  134. )
  135. }
  136. }, {
  137. md: 24,
  138. isShow: true,
  139. name: 'el-input',
  140. attributes: { placeholder: '排序数字越小越靠前', type: 'number' },
  141. formItemAttributes: {
  142. label: '排序',
  143. prop: 'sortNum',
  144. rules: []
  145. }
  146. }, {
  147. md: 24,
  148. isShow: true,
  149. name: 'slot-component',
  150. formItemAttributes: {
  151. label: '上传图片',
  152. prop: 'imgUrl',
  153. rules: [...required]
  154. },
  155. render: (h, { props, onInput }) => {
  156. var { value } = props
  157. return (
  158. <div>
  159. <ImageUpload fileList={this.formData.imgUrl} fileType={['image']} limit={1} isEdit={this.formDialogType !== 2} />
  160. <div style="color: #EA8000">上传后在小程序首页自助服务展示</div>
  161. </div>
  162. )
  163. }
  164. }]
  165. }
  166. },
  167. methods: {
  168. // 列表请求函数
  169. getList: listPageV2,
  170. // 列表导出函数
  171. exportList: pageExport,
  172. // 表格列解析渲染数据更改
  173. columnParsing(item, defaultData) {
  174. if (item.jname === 'imgUrl') {
  175.         defaultData.render = (h, { row, index, column }) => {
  176.           return (
  177.             <div style="padding:0 6px;cursor: pointer;">
  178.               {row.imgUrl ? row.imgUrl.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="cover" style="width:80px;height:80px;" />) : null}
  179.             </div>
  180.           )
  181.         }
  182.       }
  183. return defaultData
  184. },
  185. // 监听勾选变化
  186. selectionChange(data) {
  187. this.recordSelected = data
  188. },
  189. // 表格操作列
  190. operation() {
  191. return this.operationBtn({
  192. edit: {
  193. click: ({ row, index, column }) => {
  194. getDetail({ id: row.id }).then(res => {
  195. Object.assign(this.formData, res.data,{
  196. imgUrl:res.data?.imgUrl? res.data?.imgUrl?.split(",").map(item=>({url:item})) : []
  197. })
  198. console.log(this.formData)
  199. this.formDialogType = 1
  200. this.openForm()
  201. })
  202. }
  203. },
  204. detail: {
  205. click: ({ row, index, column }) => {
  206. getDetail({ id: row.id }).then(res => {
  207. Object.assign(this.formData, res.data,{
  208. imgUrl:res.data?.imgUrl? res.data?.imgUrl?.split(",").map(item=>({url:item})) : []
  209. })
  210. console.log(this.formData)
  211. this.formDialogType = 2
  212. this.openForm()
  213. })
  214. }
  215. },
  216. expenseApply: {
  217. click: ({ row, index, column }) => {
  218. }
  219. },
  220. serviceOrderDetail: {
  221. click: ({ row, index, column }) => {
  222. }
  223. }
  224. })
  225. },
  226. addData() {
  227. this.formDialogType = 0
  228. this.openForm()
  229. },
  230. openForm() {
  231. this.formDialog = true;
  232. },
  233. formCancel() {
  234. this.$refs.formRef.$refs.inlineForm.clearValidate()
  235. this.$data.formData = this.$options.data().formData
  236. this.formDialog = false
  237. },
  238. formConfirm() {
  239. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  240. if (valid) {
  241. (save)({
  242. ...this.formData,
  243. imgUrl:this.formData.imgUrl.map(item=>item.url).join(",")
  244. }).then(res => {
  245. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  246. this.formCancel()
  247. this.$refs.pageRef.refreshList()
  248. })
  249. }
  250. })
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. .tab{
  257. padding: 20px 20px 0 20px;
  258. }
  259. </style>