editPlan.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="title" @clickLeft="back">
  5. </uni-nav-bar>
  6. <view class="scrollable-tabs" ref="tabsContainer">
  7. <u-subsection :list="tabs" :current="currentIndex" @change="(e)=>sectionChange(e)"></u-subsection>
  8. </view>
  9. <accessoryList title="配件回收清单" ref="accessoryRef" :itemList="accessList" v-show="currentValue == 2" />
  10. <DemandInfo :demandForm="demandForm" v-show="currentValue == 3" :itemList="productDetail" />
  11. <PlanInfo :planForm="planForm" v-show="currentValue == 4" />
  12. <AfterSales ref="salesRef" v-show="currentValue == 5" :itemList="productDetail" :type="type"
  13. :isReport="isReport" />
  14. <ContactList ref="contactRef" :type="type" v-show="currentValue == 6" :itemList="contactInfoVOS"
  15. :isReport="isReport" />
  16. <SchemeList ref="schemeRef" v-show="currentValue == 7" :type='type' :itemList="costListVOS" />
  17. <ReportInfo v-show="currentValue == 1" />
  18. <view class="footerButton" v-if="isDisable">
  19. <u-button type="default" text="返回" @click="back"></u-button>
  20. <u-button type="primary" text="报工" @click="back"></u-button>
  21. <u-button type="primary" @click="save" text="保存"></u-button>
  22. </view>
  23. <!-- <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  24. valueKey="id" textKey="name" childrenKey="children" /> -->
  25. <u-toast ref="uToast"></u-toast>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. getSalesWorkOrderById,
  31. updateScheme
  32. } from '@/api/salesServiceManagement/workOrder/index.js';
  33. import {
  34. contactDetail
  35. } from '@/api/saleManage/contact/index.js';
  36. import accessoryList from './accessoryList.vue';
  37. import ReportInfo from './reportInfo.vue';
  38. import AfterSales from '@/pages/salesServiceManagement/demandList/components/AfterSales.vue';
  39. import ContactList from '@/pages/salesServiceManagement/demandList/components/contactList.vue';
  40. import PlanInfo from './planInfo.vue';
  41. import DemandInfo from './demandInfo.vue';
  42. import SchemeList from './schemeList.vue';
  43. import {
  44. getByCode
  45. } from '@/api/pda/common.js';
  46. import {
  47. listOrganizations,
  48. getUserPage
  49. } from '@/api/myTicket/index.js';
  50. let resData = {};
  51. let contractInfo = {};
  52. export default {
  53. components: {
  54. SchemeList,
  55. PlanInfo,
  56. DemandInfo,
  57. AfterSales,
  58. ContactList,
  59. ReportInfo,
  60. accessoryList
  61. },
  62. computed: {
  63. isDisable() {
  64. let flag = this.type != 'view';
  65. return flag;
  66. },
  67. isReport() {
  68. let flag = this.type != 'view' ? true : false;
  69. return flag;
  70. },
  71. currentIndex() {
  72. return this.tabs.findIndex(item => item.id == this.currentValue);
  73. }
  74. },
  75. data() {
  76. return {
  77. title: '修改工单',
  78. type: 'edit',
  79. Usertype: '',
  80. tabs: [{
  81. name: '售后对象',
  82. id: 5
  83. }, {
  84. name: '联系人',
  85. id: 6
  86. },
  87. {
  88. name: '方案',
  89. id: 7
  90. }, {
  91. name: '需求信息',
  92. id: 3
  93. }, {
  94. name: '计划信息',
  95. id: 4
  96. },
  97. ],
  98. listData: [], // 部门数据
  99. userList: [], // 执行人列表
  100. demandForm: {}, // 需求基本信息
  101. planForm: {}, // 计划基本信息
  102. productDetail: [], // 售后对象
  103. contactInfoVOS: [], // 联系人
  104. costListVOS: [], // 方案
  105. currentValue: 5,
  106. accessList: [], // 配件回收
  107. }
  108. },
  109. onLoad(params) {
  110. this.type = params.type;
  111. this.title = params.type == 'view' ? '工单详情' : params.type == 'edit' ? '修改工单' : '报工';
  112. if (params.type == 'report') {
  113. this.tabs.unshift({
  114. name: '报工信息',
  115. id: 1
  116. }, {
  117. name: '配件回收',
  118. id: 2
  119. });
  120. this.currentValue = 1;
  121. }
  122. this.getDetails(params.id);
  123. },
  124. onUnload() {},
  125. created() {},
  126. methods: {
  127. async getDetails(id) {
  128. // await this.getByData();
  129. // this.getDept();
  130. const res = await getSalesWorkOrderById(id);
  131. console.log(res, 'res ----')
  132. this.accessList = res.accessoryApply?.detailList || []
  133. this.contactData(res.afterSalesDemandVO.contactId, 'init');
  134. resData = res;
  135. this.costListVOS = res.costListVOS;
  136. this.demandData(res.afterSalesDemandVO);
  137. this.planData(res.afterSalesPlanVO);
  138. },
  139. // 工单绑定的客户数据
  140. async contactData(id) {
  141. let {
  142. base
  143. } = await contactDetail(id);
  144. base.contactName = base.name;
  145. contractInfo = base;
  146. },
  147. // 需求数据
  148. async demandData(data) {
  149. this.contactInfoVOS = data.contactInfoVOS || [];
  150. this.productDetail = data.productDetail || [];
  151. let fault_level = await this.getByData('fault_level', data.faultLevel);
  152. this.demandForm = {
  153. code: data.code,
  154. name: data.name,
  155. contactName: data.contactName,
  156. orderCode: data.orderCode,
  157. contactAddress: data.contactAddress,
  158. expectedTime: data.expectedTime,
  159. createUserName: data.createUserName,
  160. fault_level,
  161. }
  162. },
  163. // 计划信息
  164. async planData(data) {
  165. let isSyncBill = data.isSyncBill == '0' ? '否' : data.isSyncBill == '1' ? '是' : ''
  166. let urgent = await this.getByData('urgent_type', data.urgent);
  167. this.planForm = {
  168. code: data.code,
  169. name: data.name,
  170. isSyncBill,
  171. executeGroupName: data.executeGroupName,
  172. executeUserName: data.executeUserName,
  173. remark: data.remark,
  174. duration: data.duration,
  175. durationUnit: data.durationUnit,
  176. urgent,
  177. }
  178. },
  179. async getByData(code, value) {
  180. const codeValue = await getByCode(code);
  181. let label = '';
  182. codeValue.forEach((el) => {
  183. if (el[value]) {
  184. label = el[value];
  185. return;
  186. }
  187. })
  188. return label || ''
  189. },
  190. getDept() {
  191. listOrganizations(1).then(data => {
  192. this.listData = data;
  193. })
  194. },
  195. save() {
  196. let productDetail = this.$refs.salesRef.getTabData();
  197. let contactInfoVOS = this.$refs.contactRef.getTabData();
  198. let costListVOS = this.$refs.schemeRef.getTabData();
  199. let obj = resData.afterSalesDemandVO;
  200. let data = {
  201. attachments: resData.attachments,
  202. costListVOS: costListVOS,
  203. faultPhenomenon: resData.inFactDuration,
  204. faultReason: resData.faultReason,
  205. id: resData.id,
  206. inFactDuration: resData.inFactDuration,
  207. maintenanceProcess: resData.maintenanceProcess,
  208. salesDemandUpdatePO: {
  209. orderCode: obj.orderCode,
  210. orderId: obj.orderId,
  211. name: obj.name,
  212. faultLevel: obj.faultLevel ? String(obj.faultLevel) : '',
  213. code: obj.code,
  214. expectedTime: obj.expectedTime || '',
  215. contactAddress: obj.contactAddress || '',
  216. id: obj.id,
  217. }
  218. }
  219. productDetail.map((el) => {
  220. delete el.produceTime;
  221. })
  222. data.salesDemandUpdatePO.productDetail = productDetail;
  223. data.salesDemandUpdatePO.contractInfo = contractInfo;
  224. data.salesDemandUpdatePO.contactInfoVOS = contactInfoVOS;
  225. uni.showLoading({
  226. title: '加载中'
  227. })
  228. updateScheme(data).then(res => {
  229. this.$refs.uToast.show({
  230. type: "success",
  231. message: "操作成功",
  232. })
  233. uni.hideLoading();
  234. this.back();
  235. }).catch(e => {
  236. uni.hideLoading();
  237. })
  238. },
  239. // confirm(data, name) {
  240. // this.form.executeGroupName = name
  241. // this.form.executeGroupId = data[0]
  242. // this.form.executeUserName = ''
  243. // this.form.executeUserId = ''
  244. // this.getUser(data[0])
  245. // },
  246. // getUser(deptCode) {
  247. // getUserPage({
  248. // pageNum: 1,
  249. // size: -1,
  250. // groupId: deptCode
  251. // }).then(data => {
  252. // this.userList = data.list.map(item => {
  253. // item.text = item.name
  254. // item.value = item.id
  255. // return item
  256. // })
  257. // })
  258. // },
  259. sectionChange(index) {
  260. this.currentValue = this.tabs[index].id;
  261. },
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. /deep/.u-subsection__item__text {
  267. font-size: 28rpx !important;
  268. }
  269. /deep/.u-cell__body__content {
  270. flex: none;
  271. margin-right: 16rpx;
  272. }
  273. /deep/ .time_select .uni-data-tree-input {
  274. width: 200rpx;
  275. }
  276. /deep/ .executor_user {
  277. background: #fff;
  278. }
  279. .footerButton {
  280. width: 100%;
  281. height: 84rpx;
  282. display: flex;
  283. position: fixed;
  284. bottom: 0;
  285. z-index: 10;
  286. justify-content: space-between;
  287. /deep/.u-button {
  288. height: 100%;
  289. width: 30%;
  290. }
  291. >view {
  292. flex: 1;
  293. }
  294. }
  295. .scrollable-tabs {
  296. white-space: nowrap;
  297. /* 防止选项卡换行 */
  298. overflow-x: auto;
  299. /* 启用横向滚动 */
  300. -webkit-overflow-scrolling: touch;
  301. /* 优化iOS滚动体验 */
  302. /deep/ .u-subsection {
  303. overflow-x: auto;
  304. }
  305. /deep/ .u-subsection__item__text {
  306. width: 144rpx;
  307. text-align: center;
  308. display: inline-block;
  309. }
  310. }
  311. </style>