index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <zj-page-layout :hasFooter="true">
  3. <view class="all-container">
  4. <view class="address-container card" @tap="chooseAddress">
  5. <view class="common-title"><text>*</text>客户信息</view>
  6. <view class="main">
  7. <view class="left">
  8. <view class="icon"><text class="iconfont icon-dingwei1"></text></view>
  9. <view class="nodata" v-if="!addressInfo">选择联系人地址</view>
  10. <view class="hasdata" v-else>
  11. <view class="name"
  12. >{{ addressInfo.name }}<text>{{ addressInfo.phone }}</text></view
  13. >
  14. <view class="address ellipsis-2"
  15. >{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.area }}{{ addressInfo.street
  16. }}{{ addressInfo.address }}{{ addressInfo.houseNo }}</view
  17. >
  18. </view>
  19. </view>
  20. <text class="right iconfont icon-jinru"></text>
  21. </view>
  22. </view>
  23. <view class="service-container card">
  24. <view class="common-title">服务信息</view>
  25. <view class="item">
  26. <view class="label"><text>*</text>工单类型</view>
  27. <view class="value">{{ typeName }}</view>
  28. </view>
  29. <view class="item" v-if="isWorkerUser">
  30. <view class="label"><text>*</text>所属网点</view>
  31. <view class="picker" @tap="isShowWebsitDialog = true">
  32. <text class="value" v-if="websit">{{ websit.name }}</text>
  33. <text class="placeholder" v-else>请选择</text>
  34. <text class="iconfont icon-jinru"></text>
  35. </view>
  36. </view>
  37. <view class="item">
  38. <view class="label"><text>*</text>预约上门时间</view>
  39. <view class="picker" @tap="isShowDatePicker = true">
  40. <text class="value" v-if="date">{{ date }}</text>
  41. <text class="placeholder" v-else>请选择</text>
  42. <text class="iconfont icon-jinru"></text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="product-container card">
  47. <view class="title">
  48. <view class="common-title"><text>*</text>产品信息</view>
  49. <view class="right" @tap="toChooseProduct"
  50. ><u-icon name="plus-circle" color="#3D8FFD" size="18"></u-icon>添加</view
  51. >
  52. </view>
  53. <view class="list">
  54. <view class="item" v-for="(item, index) in productList" :key="index">
  55. <image :src="item.imgUrl" mode="aspectFill"></image>
  56. <view class="main">
  57. <view class="name">{{ item.smallName }}</view>
  58. <view class="tags">
  59. <view class="it">{{ item.brandName }}</view>
  60. </view>
  61. <u-number-box min="1" v-model="item.num">
  62. <view slot="minus" class="ctrl">
  63. <u-icon name="minus" color="#FFFFFF" size="10"></u-icon>
  64. </view>
  65. <text slot="input" class="input">{{ item.num }}</text>
  66. <view slot="plus" class="ctrl">
  67. <u-icon name="plus" color="#FFFFFF" size="10"></u-icon>
  68. </view>
  69. </u-number-box>
  70. </view>
  71. <view class="del" @tap="deleteProduct(item, index)"><text class="iconfont icon-shanchu"></text></view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="remark-container card">
  76. <view class="common-title" v-if="typeName.indexOf('维修') >= 0"><text>*</text>故障描述</view>
  77. <view class="common-title" v-else>备注信息</view>
  78. <u--textarea v-model="remark" placeholder="请输入内容" border="none" autoHeight></u--textarea>
  79. </view>
  80. </view>
  81. <template slot="footer">
  82. <view class="footer-btn-group">
  83. <u-button text="提交服务单" type="primary" @click="submitData"></u-button>
  84. </view>
  85. </template>
  86. <zjDialogPicker
  87. ref="websitDialog"
  88. :isShow="isShowWebsitDialog"
  89. :multiple="false"
  90. :styleType="2"
  91. :title="'所属网点'"
  92. :list="websitList"
  93. :keyName="'name'"
  94. @cancel="isShowWebsitDialog = false"
  95. @confirm="confirmWebsitDialog"
  96. >
  97. </zjDialogPicker>
  98. <u-datetime-picker
  99. :show="isShowDatePicker"
  100. v-model="datePickerValue"
  101. mode="date"
  102. :formatter="formatter"
  103. @cancel="isShowDatePicker = false"
  104. @close="isShowDatePicker = false"
  105. @confirm="confirmDate"
  106. :minDate="minDate"
  107. ></u-datetime-picker>
  108. </zj-page-layout>
  109. </template>
  110. <script>
  111. import zjDialogPicker from '@/components/zj-dialog/zj-dialog-picker.vue'
  112. export default {
  113. components: {
  114. zjDialogPicker
  115. },
  116. data() {
  117. return {
  118. typeId: '',
  119. typeName: '',
  120. addressInfo: null,
  121. userInfo: {},
  122. websit: null,
  123. websitList: [],
  124. isShowWebsitDialog: false,
  125. date: '',
  126. datePickerValue: Number(new Date()),
  127. minDate: Number(new Date()),
  128. isShowDatePicker: false,
  129. productList: [],
  130. remark: ''
  131. }
  132. },
  133. computed: {
  134. isWorkerUser() {
  135. // 是否师傅
  136. return this.userInfo && this.userInfo.type === 'WORKER'
  137. }
  138. },
  139. async onLoad({ typeId, typeName }) {
  140. this.typeId = typeId
  141. this.typeName = typeName
  142. this.getWebsitList()
  143. this.userInfo = await this.$getUserInfo()
  144. // 接收地址信息
  145. this.crossPage.$on('chooseAddress', result => {
  146. this.addressInfo = result
  147. })
  148. // 接收产品分类
  149. this.crossPage.$on('chooseClassify', result => {
  150. let index = this.productList.findIndex(item => item.smallId == result.smallId && item.brandId == result.brandId)
  151. if (index !== -1) {
  152. this.productList.splice(index, 1, result)
  153. } else {
  154. this.productList.push(result)
  155. }
  156. })
  157. },
  158. onUnload() {
  159. this.crossPage.$off('chooseAddress')
  160. this.crossPage.$off('chooseClassify')
  161. },
  162. methods: {
  163. formatter(type, value) {
  164. if (type === 'year') {
  165. return `${value}年`
  166. }
  167. if (type === 'month') {
  168. return `${value}月`
  169. }
  170. if (type === 'day') {
  171. return `${value}日`
  172. }
  173. return value
  174. },
  175. // 去选择地址
  176. chooseAddress() {
  177. this.$navToPage({
  178. url: '/packageMine/pages/address/list?isChoose=' + true
  179. })
  180. },
  181. getWebsitList() {
  182. this.$api.get('/user/apply/websit').then(res => {
  183. this.websitList = res.data
  184. })
  185. },
  186. confirmWebsitDialog(e) {
  187. this.websit = this.websitList[e[0]]
  188. this.isShowWebsitDialog = false
  189. },
  190. toChooseProduct() {
  191. this.$navToPage({
  192. url: '/packageWorkorder/pages/create/classify'
  193. })
  194. },
  195. deleteProduct(item, index) {
  196. this.$modal({
  197. content: `确定删除${item.smallName}吗?`
  198. })
  199. .then(() => {
  200. this.productList.splice(index, 1)
  201. })
  202. .catch(() => {})
  203. },
  204. confirmDate(e) {
  205. this.isShowDatePicker = false
  206. let time = new Date(e.value)
  207. let y = time.getFullYear()
  208. let m = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1
  209. let d = time.getDate() < 10 ? '0' + time.getDate() : time.getDate()
  210. let hh = time.getHours() < 10 ? '0' + time.getHours() : time.getHours()
  211. let mm = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes()
  212. let ss = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds()
  213. this.date = `${y}-${m}-${d}`
  214. },
  215. submitData() {
  216. if (!this.addressInfo) return this.$toast('请选择客户信息')
  217. if (!this.websit && this.isWorkerUser) return this.$toast('请选择所属网点')
  218. if (!this.date) return this.$toast('请选择预约上门时间')
  219. if (this.productList.length < 1) return this.$toast('请添加产品信息')
  220. if (this.typeName.indexOf('维修') >= 0 && !this.remark) return this.$toast('请填写故障描述')
  221. this.$api
  222. .postJson('/pg/order/base/save', {
  223. orderSmallType: this.typeId,
  224. userAddressId: this.addressInfo.userAddressId,
  225. websitId: this.websit ? this.websit.websitId : '',
  226. appointmentTime: this.date + ' 00:00:00',
  227. orderProducts: this.productList,
  228. remark: this.remark
  229. })
  230. .then(res => {
  231. this.$successToast()
  232. if (this.isWorkerUser) {
  233. this.$navToPage(
  234. {
  235. url: `/packageWorkorder/pages/orderList`
  236. },
  237. 'redirectTo'
  238. )
  239. } else {
  240. this.$navToPage({
  241. url: `/packageWorkorder/pages/userWorkorderList`
  242. })
  243. }
  244. })
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss" scoped>
  250. .card {
  251. @include zj-card;
  252. margin-top: 20rpx;
  253. padding: 30rpx;
  254. }
  255. .common-title {
  256. font-size: 32rpx;
  257. font-weight: 500;
  258. text {
  259. color: $error-color;
  260. font-weight: normal;
  261. }
  262. }
  263. .all-container {
  264. padding: 0 20rpx;
  265. }
  266. .address-container {
  267. .main {
  268. display: flex;
  269. justify-content: space-between;
  270. align-items: center;
  271. margin-top: 30rpx;
  272. }
  273. .right {
  274. font-size: 32rpx;
  275. color: $sec-font;
  276. flex-shrink: 0;
  277. }
  278. .left {
  279. display: flex;
  280. align-items: center;
  281. margin-right: 20rpx;
  282. .icon {
  283. width: 52rpx;
  284. height: 52rpx;
  285. border-radius: 50%;
  286. background: $theme-color;
  287. display: flex;
  288. flex-shrink: 0;
  289. justify-content: center;
  290. align-items: center;
  291. margin-right: 20rpx;
  292. .iconfont {
  293. font-size: 36rpx;
  294. color: #ffffff;
  295. }
  296. }
  297. .nodata {
  298. font-size: 28rpx;
  299. color: #999999;
  300. }
  301. .hasdata {
  302. .name {
  303. font-size: 32rpx;
  304. color: #333333;
  305. text {
  306. color: #999999;
  307. font-size: 28rpx;
  308. margin-left: 16rpx;
  309. }
  310. }
  311. .address {
  312. font-size: 28rpx;
  313. color: #666666;
  314. line-height: 34rpx;
  315. margin-top: 10rpx;
  316. }
  317. }
  318. }
  319. }
  320. .service-container {
  321. .item {
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-between;
  325. height: 50rpx;
  326. margin-top: 30rpx;
  327. .label {
  328. margin-right: 30rpx;
  329. text {
  330. color: $error-color;
  331. }
  332. }
  333. .picker {
  334. .placeholder {
  335. color: $sec-font;
  336. }
  337. .iconfont {
  338. margin-left: 12rpx;
  339. color: $sec-font;
  340. }
  341. }
  342. }
  343. }
  344. .product-container {
  345. .title {
  346. display: flex;
  347. align-items: center;
  348. justify-content: space-between;
  349. .right {
  350. color: $theme-color;
  351. font-size: 28rpx;
  352. display: flex;
  353. align-items: center;
  354. ::v-deep .u-icon {
  355. margin-right: 8rpx;
  356. }
  357. }
  358. }
  359. .list {
  360. .item {
  361. padding: 30rpx 0;
  362. border-bottom: 1px solid #eaeaea;
  363. display: flex;
  364. &:last-child {
  365. border: none;
  366. }
  367. image {
  368. width: 100rpx;
  369. height: 100rpx;
  370. }
  371. .main {
  372. flex: 1;
  373. margin-left: 20rpx;
  374. margin-right: 20rpx;
  375. .name {
  376. font-size: 28rpx;
  377. font-weight: 500;
  378. line-height: 36rpx;
  379. }
  380. .tags {
  381. display: flex;
  382. margin-top: 12rpx;
  383. margin-bottom: 16rpx;
  384. .it {
  385. font-size: 24rpx;
  386. color: $theme-color;
  387. background: rgba($color: $theme-color, $alpha: 0.3);
  388. padding: 8rpx 12rpx;
  389. border-radius: 8rpx;
  390. }
  391. }
  392. .input {
  393. width: 30rpx;
  394. text-align: center;
  395. padding: 0 10px;
  396. }
  397. .ctrl {
  398. width: 36rpx;
  399. height: 36rpx;
  400. background-color: $theme-color;
  401. border-radius: 50%;
  402. display: flex;
  403. justify-content: center;
  404. align-items: center;
  405. }
  406. }
  407. .del {
  408. text {
  409. font-size: 36rpx;
  410. color: $sec-font;
  411. }
  412. }
  413. }
  414. }
  415. }
  416. .remark-container {
  417. ::v-deep .u-textarea {
  418. margin-top: 20rpx;
  419. padding: 20rpx 20rpx;
  420. min-height: 200rpx;
  421. background: #f5f5f5;
  422. }
  423. }
  424. </style>