repair.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents"
  3. :operationColumnWidth="80" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
  4. :column-parsing="columnParsing" :operation="operation()" :exportList="exportList" :replaceOrNotMap="true" expCode="exp_wx">
  5. </template-page>
  6. </template>
  7. <script>
  8. import TemplatePage from '@/components/template/template-page-1.vue'
  9. import import_mixin from '@/components/template/import_mixin.js'
  10. import ImageUpload from '@/components/file-upload'
  11. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  12. import { del, getMainList, getTypeList } from "@/api/workOrder/settlementStandardInstall";
  13. import { listPageV2, pageExport, add, edit } from "@/api/workOrder/settlementStandardRepair";
  14. import { getSourceList } from "@/api/workOrder/settlementStandardInstall";
  15. import { thousands } from '@/utils/common'
  16. import operation_mixin from '@/components/template/operation_mixin.js'
  17. export default {
  18. components: { TemplatePage, ImageUpload },
  19. mixins: [import_mixin, operation_mixin],
  20. data() {
  21. return {
  22. // 表格属性
  23. tableAttributes: {
  24. // 启用勾选列
  25. selectColumn: false
  26. },
  27. // 表格事件
  28. tableEvents: {
  29. 'selection-change': this.selectionChange
  30. },
  31. // 勾选选中行
  32. recordSelected: [],
  33. /** 表单变量 */
  34. formDialogType: 0,
  35. formDialogTitles: ["新增", "编辑", "详情"],
  36. formDialog: false,
  37. formData: {
  38. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  39. },
  40. editIndex: null,
  41. mainList: [],
  42. smallList: [],
  43. typeList: [],
  44. sourceList: []
  45. }
  46. },
  47. computed: {
  48. // 事件组合
  49. optionsEvensGroup() {
  50. return [
  51. [
  52. [
  53. this.optionsEvensAuth("add_wx", {
  54. click: this.addData
  55. })
  56. ]
  57. ]
  58. ]
  59. },
  60. // 更多参数
  61. moreParameters() {
  62. return []
  63. },
  64. formItems() {
  65. return []
  66. }
  67. },
  68. created() {
  69. this.getMainList()
  70. this.getTypeList()
  71. this.getSourceList()
  72. },
  73. methods: {
  74. // 列表请求函数
  75. getList: listPageV2,
  76. getList(p) {
  77. try {
  78. var pam = JSON.parse(JSON.stringify(p))
  79. this.editIndex = null
  80. return listPageV2(pam)
  81. } catch (error) {
  82. console.log(error)
  83. }
  84. },
  85. // 列表导出函数
  86. exportList: pageExport,
  87. // 表格列解析渲染数据更改
  88. columnParsing(item, defaultData) {
  89. if (item.jname === 'orderChannelText') {
  90. defaultData.render = (h, { row, index, column }) => {
  91. return this.editIndex == index ? (
  92. <div class="redbordererr">
  93. <el-form-item prop={`tableData.${index}.orderChannelId`} rules={[{ required: true, message: '工单来源不能为空', trigger: 'blur' }]}>
  94. <el-select value={{ dictCode: row.orderChannelId, dictValue: row.orderChannelText }} value-key="dictCode" placeholder="请选择"
  95. onInput={(val) => {
  96. row.orderChannelText = val.dictValue
  97. row.orderChannelId = val.dictCode
  98. }}>
  99. {
  100. this.sourceList.map((item, index) => {
  101. return <el-option key={item.dictCode} label={item.dictValue} value={item}></el-option>
  102. })
  103. }
  104. </el-select>
  105. </el-form-item>
  106. </div>
  107. ) : (<div style="padding: 6px;">{row.orderChannelText}</div>)
  108. }
  109. }
  110. if (item.jname === 'typeName') {
  111. defaultData.render = (h, { row, index, column }) => {
  112. return this.editIndex == index ? (
  113. <div class="redbordererr">
  114. <el-form-item prop={`tableData.${index}.type`} rules={[{ required: true, message: '工单类型不能为空', trigger: 'blur' }]}>
  115. <el-select value-key="id" value={{ orderSmallTypeText: row.typeName, id: row.type }} placeholder="请选择"
  116. onInput={(val) => {
  117. row.type = val.id
  118. row.typeName = val.orderSmallTypeText
  119. }}>
  120. {
  121. this.typeList.map((item, index) => {
  122. return <el-option key={item.id} label={item.orderSmallTypeText} value={item}></el-option>
  123. })
  124. }
  125. </el-select>
  126. </el-form-item>
  127. </div>
  128. ) : (<div style="padding: 6px;">{row.typeName}</div>)
  129. }
  130. }
  131. if (item.jname === 'parentCategoryName') {
  132. defaultData.render = (h, { row, index, column }) => {
  133. return this.editIndex == index ? (
  134. <div class="redbordererr">
  135. <el-form-item prop={`tableData.${index}.parentCategoryId`} rules={[{ required: true, message: '产品大类不能为空', trigger: 'blur' }]}>
  136. <el-select value={{ categoryId: row.parentCategoryId, name: row.parentCategoryName }} value-key="name" placeholder="请选择"
  137. onInput={(val) => {
  138. row.parentCategoryId = val.categoryId
  139. row.parentCategoryName = val.name
  140. row.categoryName = ''
  141. row.categoryId = ''
  142. this.smallList = [...[{ name: '通用', categoryId: '0' }], ...(val.children ? val.children : [])]
  143. }}>
  144. {
  145. this.mainList.map((item, index) => {
  146. return <el-option key={item.categoryId} label={item.name} value={item}></el-option>
  147. })
  148. }
  149. </el-select>
  150. </el-form-item>
  151. </div>
  152. ) : (<div style="padding: 6px;">{row.parentCategoryName}</div>)
  153. }
  154. }
  155. if (item.jname === 'categoryName') {
  156. defaultData.render = (h, { row, index, column }) => {
  157. return this.editIndex == index ? (
  158. <div class="redbordererr">
  159. <el-form-item prop={`tableData.${index}.categoryId`} rules={[{ required: true, message: '产品小类不能为空', trigger: 'blur' }]}>
  160. <el-select value={{ categoryId: row.categoryId, name: row.categoryName }} value-key="name" placeholder="请选择"
  161. onInput={(val) => {
  162. row.categoryName = val.name
  163. row.categoryId = val.categoryId
  164. }}>
  165. {
  166. this.smallList.map((item, index) => {
  167. return <el-option key={item.id} label={item.name} value={item}></el-option>
  168. })
  169. }
  170. </el-select>
  171. </el-form-item>
  172. </div>
  173. ) : (<div style="padding: 6px;">{row.categoryName}</div>)
  174. }
  175. }
  176. if (item.jname === 'label') {
  177. defaultData.render = (h, { row, index, column }) => {
  178. return this.editIndex == index ? (
  179. <div class="redbordererr">
  180. <el-form-item prop={`tableData.${index}.label`} rules={[{ required: true, message: '质保类型不能为空', trigger: 'blur' }]}>
  181. <el-select value={row.label} placeholder="请选择"
  182. onInput={(val) => {
  183. row.label = val
  184. }}>
  185. {
  186. [{ id: 'INSIDE', name: '保内' }, { id: 'OUT', name: '保外' }].map((item, index) => {
  187. return <el-option key={item.id} label={item.name} value={item.id}></el-option>
  188. })
  189. }
  190. </el-select>
  191. </el-form-item>
  192. </div>
  193. ) : (<div style="padding: 6px;">{row.label}</div>)
  194. }
  195. }
  196. if (item.jname === 'repairAmount') {
  197. defaultData.render = (h, { row, index, column }) => {
  198. return this.editIndex == index ? (
  199. <div class="redbordererr">
  200. <el-form-item prop={`tableData.${index}.repairAmount`} rules={[{ required: true, message: '上门票不能为空', trigger: 'blur' }]}>
  201. <el-input type="text" value={row.repairAmount} placeholder="请输入"
  202. onInput={(val) => {
  203. row.repairAmount = val
  204. }}>
  205. </el-input>
  206. </el-form-item>
  207. </div>
  208. ) : (<div style="padding: 6px;">{thousands(row.repairAmount)}</div>)
  209. }
  210. }
  211. if (item.jname === 'normAmount') {
  212. defaultData.render = (h, { row, index, column }) => {
  213. return this.editIndex == index ? (
  214. <div class="redbordererr">
  215. <el-form-item prop={`tableData.${index}.normAmount`} rules={[{ required: true, message: '维修费结算比例不能为空', trigger: 'blur' }]}>
  216. <div style="display:flex;">
  217. <el-input type="text" value={row.normAmount} placeholder="请输入"
  218. onInput={(val) => {
  219. row.normAmount = val
  220. }}>
  221. </el-input>
  222. </div>
  223. </el-form-item>
  224. </div>
  225. ) : (<div style="padding: 6px;">{row.normAmount} %</div>)
  226. }
  227. }
  228. if (item.jname === 'remark') {
  229. defaultData.render = (h, { row, index, column }) => {
  230. return this.editIndex == index ? (
  231. <div class="redbordererr">
  232. <el-form-item prop={`tableData.${index}.remark`}>
  233. <el-input type="text" value={row.remark} placeholder="请输入"
  234. onInput={(val) => {
  235. row.remark = val
  236. }}>
  237. </el-input>
  238. </el-form-item>
  239. </div>
  240. ) : (<div style="padding: 6px;">{row.remark}</div>)
  241. }
  242. defaultData.columnAttributes.width = 200
  243. }
  244. return defaultData
  245. },
  246. // 监听勾选变化
  247. selectionChange(data) {
  248. this.recordSelected = data
  249. },
  250. operation() {
  251. return this.operationBtn({
  252. edit_wx: {
  253. conditions: ({ row, index, column }) => {
  254. return row.id
  255. },
  256. name: ({ row, index, column }) => {
  257. return this.editIndex == index ? '确定' : '编辑'
  258. },
  259. click: ({ row, index, column }) => {
  260. this.$refs.pageRef.tableForm().validate((valid) => {
  261. if (valid) {
  262. if (this.editIndex != index) {
  263. row = Object.assign(row, {
  264. label: row.label == '保内' ? 'INSIDE' : 'OUT'
  265. })
  266. this.mainList.forEach(item => {
  267. if (item.categoryId == row.parentCategoryId) {
  268. this.smallList = [...[{ name: '通用', categoryId: '0' }], ...(item.children ? item.children : [])]
  269. }
  270. })
  271. this.editIndex = index
  272. } else {
  273. this.edit(row)
  274. }
  275. } else {
  276. console.log('error submit!!');
  277. return false;
  278. }
  279. });
  280. }
  281. },
  282. save_wx: {
  283. conditions: ({ row, index, column }) => {
  284. return !row.id
  285. },
  286. click: ({ row, index, column }) => {
  287. this.$refs.pageRef.tableForm().validate((valid) => {
  288. if (valid) {
  289. this.add(row)
  290. } else {
  291. console.log('error submit!!');
  292. return false;
  293. }
  294. });
  295. }
  296. },
  297. del_wx: {
  298. prompt: "请确认是否删除该数据, 是否继续?",
  299. click: ({ row, index, column }) => {
  300. if (row.id) {
  301. del({
  302. id: row.id
  303. }).then(res => {
  304. if (res.code == 200) {
  305. this.$message({ type: 'success', message: '删除成功!' })
  306. this.$refs.pageRef.refreshList()
  307. } else {
  308. this.$message.error(res.msg);
  309. }
  310. })
  311. } else {
  312. this.$refs.pageRef.deleteRowData(0);
  313. this.editIndex = null
  314. }
  315. }
  316. }
  317. })
  318. },
  319. getMainList() {
  320. getMainList({ type: 2 }).then(res => {
  321. this.mainList = res.data
  322. })
  323. },
  324. getTypeList() {
  325. getTypeList({ pageNum: 1, pageSize: -1, params: [{ param: 'a.order_type', compare: '=', value: 'REPAIR' }, { param: 'a.status', compare: '=', value: true }] }).then(res => {
  326. this.typeList = res.data.records
  327. })
  328. },
  329. getSourceList(){
  330. getSourceList({ pageNum: 1, pageSize: -1, params: [{param: "a.dict_type", compare: "=", value: "ORDER_CHANNEL"}] }).then(res => {
  331. this.sourceList = [...[{ dictValue: '通用', dictCode: '0' }], ...res.data.records]
  332. })
  333. },
  334. addData() {
  335. this.$refs.pageRef.tableForm().validate((valid) => {
  336. if (valid) {
  337. this.editIndex = 0
  338. this.$refs.pageRef.insertionData(0, {
  339. companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  340. settleNormType: 'REPAIR',
  341. orderChannelText: '',
  342. orderChannelId: '',
  343. typeName: '',
  344. type: '',
  345. categoryName: '',
  346. categoryId: '',
  347. parentCategoryName: '',
  348. parentCategoryId: '',
  349. label: '',
  350. normAmount: '',
  351. repairAmount: '',
  352. remark: ''
  353. })
  354. } else {
  355. console.log('error submit!!');
  356. return false;
  357. }
  358. });
  359. },
  360. openForm() {
  361. this.formDialog = true;
  362. },
  363. add(row) {
  364. add({
  365. settleNormType: 'REPAIR',
  366. orderChannelText: row.orderChannelText,
  367. orderChannelId: row.orderChannelId,
  368. typeName: row.typeName,
  369. type: row.type,
  370. parentCategoryName: row.parentCategoryName,
  371. parentCategoryId: row.parentCategoryId,
  372. categoryName: row.categoryName,
  373. categoryId: row.categoryId,
  374. label: row.label,
  375. normAmount: row.normAmount,
  376. repairAmount: row.repairAmount,
  377. remark: row.remark
  378. }).then(res => {
  379. if (res.code == 200) {
  380. this.editIndex = null
  381. this.$message({ type: 'success', message: `保存成功!` })
  382. this.$refs.pageRef.refreshList()
  383. }
  384. })
  385. },
  386. edit(row) {
  387. edit({
  388. id: row.id,
  389. settleNormType: 'REPAIR',
  390. orderChannelText: row.orderChannelText,
  391. orderChannelId: row.orderChannelId,
  392. typeName: row.typeName,
  393. type: row.type,
  394. parentCategoryName: row.parentCategoryName,
  395. parentCategoryId: row.parentCategoryId,
  396. categoryName: row.categoryName,
  397. categoryId: row.categoryId,
  398. label: row.label,
  399. normAmount: row.normAmount,
  400. repairAmount: row.repairAmount,
  401. remark: row.remark
  402. }).then(res => {
  403. if (res.code == 200) {
  404. this.editIndex = null
  405. this.$message({ type: 'success', message: `保存成功!` })
  406. this.$refs.pageRef.refreshList()
  407. }
  408. })
  409. }
  410. }
  411. }
  412. </script>
  413. <style lang="scss" scoped>
  414. .tab {
  415. padding: 20px 20px 0 20px;
  416. }
  417. .redbordererr {
  418. ::v-deep .el-form-item {
  419. margin: 0 !important;
  420. overflow: hidden;
  421. }
  422. }
  423. </style>