editPlan.vue 8.1 KB

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