index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <!-- 正确使用 u-navbar 的具名插槽 -->
  4. <u-navbar :autoBack="true" :placeholder="true" v-hideNav>
  5. <template slot="center">
  6. <view class="slot-wrap">
  7. <text @click="handleBrandClick" class="brand">{{ topInfo.brand }}</text>
  8. <text class="divider">|</text>
  9. <text @click="handleModelClick" class="model">{{ topInfo.model }}</text>
  10. <text class="divider">|</text>
  11. <text @click="handlePriceClick" class="price">¥{{ topInfo.price }}</text>
  12. </view>
  13. </template>
  14. <template slot="right">
  15. <view class="slot-right" @click="handleAddClick">
  16. <image src="/static/icons/plus.png" mode="scaleToFill" />
  17. <text>加一单</text>
  18. </view>
  19. </template>
  20. </u-navbar>
  21. <u-sticky bgColor="#fff">
  22. <u-tabs keyName="brand" :list="receiptList" @click="clickReceipt"></u-tabs>
  23. </u-sticky>
  24. <orderDetailNewView :detail="receiptDetail" :topInfo="topInfo" :orderId="orderId"
  25. :currentReceipt="currentReceipt" />
  26. <!-- 通用模态窗 -->
  27. <custom-modal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
  28. :placeholder="modalConfig.placeholder" @cancel="handleModalCancel" @confirm="handleModalConfirm" />
  29. <!-- 加一单选择模态窗 -->
  30. <u-modal :show="addOneModelShow" :title="'新增收件信息'" showCancelButton @cancel="addOneModelShow = false"
  31. @confirm="handleAddOneConfirm">
  32. <u--form>
  33. <u-form-item :model="checkModel" label="请选择品牌" prop="brand" borderBottom
  34. @click="showBrandSelector = true;">
  35. <u--input v-model="checkModel.brand" disabled disabledColor="#ffffff" placeholder="请选择品牌"
  36. @click="showBrandSelector = true;" border="none"></u--input>
  37. <u-icon slot="right" name="arrow-right"></u-icon>
  38. </u-form-item>
  39. </u--form>
  40. </u-modal>
  41. <!-- 品牌选择器 -->
  42. <u-picker :show="showBrandSelector" @confirm="handleBrandConfirm" :columns="brandColumns"
  43. @cancel='showBrandSelector = false' keyName="dictLabel"></u-picker>
  44. </view>
  45. </template>
  46. <script>
  47. import orderDetailNewView from './components/orderDetailNewView.vue'
  48. import CustomModal from './components/CustomModal.vue'
  49. export default {
  50. name: 'CustomNavbar',
  51. components: {
  52. orderDetailNewView,
  53. CustomModal
  54. },
  55. data() {
  56. return {
  57. topInfo: {
  58. brand: 'Hermes',
  59. model: 'Birkin 30',
  60. price: '125,000'
  61. },
  62. modalVisible: false,
  63. currentEditField: '',
  64. modalConfig: {
  65. title: '',
  66. value: '',
  67. placeholder: ''
  68. },
  69. item: '',
  70. orderId: '',
  71. type: '',
  72. clueId: '',
  73. // 订单详情
  74. receiptDetail: {},
  75. //接单单个订单的receiptList
  76. receiptList: [],
  77. //当前选中的收单订单
  78. currentReceipt: {},
  79. // 新加一件的信息
  80. addOneModelShow: false,
  81. showBrandSelector: false,
  82. checkModel: {
  83. brand: '',
  84. },
  85. brandColumns: [
  86. ['中国', '美国', '日本']
  87. ],
  88. //当前选择的品牌
  89. currentAddBrand: {}
  90. }
  91. },
  92. onLoad(option) {
  93. // 接收参数
  94. const { item, orderId, type, clueId } = option;
  95. console.log('接收的参数:', option);
  96. this.item = item;
  97. this.orderId = orderId;
  98. this.type = type;
  99. this.clueId = clueId;
  100. //查询订单详情
  101. this.getOrderDetail();
  102. //获取收单列表
  103. this.getReceiptList();
  104. },
  105. methods: {
  106. handleBrandClick() {
  107. this.openModal('brand', '请输入品牌', this.topInfo.brand, '请输入品牌')
  108. },
  109. handleModelClick() {
  110. this.openModal('model', '请输入型号', this.topInfo.model, '请输入型号')
  111. },
  112. handlePriceClick() {
  113. this.openModal('price', '请输入价格', this.topInfo.price, '请输入价格')
  114. },
  115. openModal(field, title, value, placeholder) {
  116. this.currentEditField = field
  117. this.modalConfig = {
  118. title,
  119. value,
  120. placeholder
  121. }
  122. this.modalVisible = true
  123. },
  124. handleModalInput(value) {
  125. this.modalConfig.value = value
  126. },
  127. handleModalCancel() {
  128. this.modalVisible = false
  129. this.currentEditField = ''
  130. },
  131. handleModalConfirm(newValue) {
  132. if (this.currentEditField) {
  133. this.topInfo[this.currentEditField] = newValue
  134. }
  135. this.modalVisible = false
  136. this.currentEditField = ''
  137. },
  138. async handleAddClick() {
  139. console.log('加一单')
  140. //判断如果当前有收单的id是‘’的话,说明是新增的收单订单
  141. //打开模态窗
  142. //选择品牌,型号。价格
  143. this.addOneModelShow = true
  144. this.$getDicts('crm_form_brand').then(res => {
  145. console.log('品牌', res)
  146. this.brandColumns = [res]
  147. })
  148. },
  149. handleBrandConfirm(data) {
  150. console.log('选择的品牌', data.value[0])
  151. this.currentAddBrand = data.value[0]
  152. this.checkModel.brand = this.currentAddBrand.dictLabel
  153. //关闭品牌选择器
  154. this.showBrandSelector = false
  155. },
  156. //查询订单详情
  157. async getOrderDetail() {
  158. const res = await uni.$u.api
  159. .getClueSendFormVoByOrderId({
  160. id: this.orderId,
  161. })
  162. console.log('订单详情', res.data);
  163. if (res.code === 200) {
  164. this.receiptDetail = res.data;
  165. }
  166. },
  167. //获取收单列表
  168. async getReceiptList() {
  169. const res = await uni.$u.api.clueReceiptFormListByOrderId(this.orderId);
  170. console.log('这里是收件列表page', res)
  171. if (res.code === 200) {
  172. this.receiptList = res.data || [];
  173. }
  174. },
  175. clickReceipt(item) {
  176. // console.log('点击了', item);
  177. this.currentReceipt = item;
  178. },
  179. async handleAddOneConfirm() {
  180. console.log('确认添加', this.currentAddBrand)
  181. //调新加一单的接口
  182. await uni.$u.api.addReceiptForm({
  183. brand: this.currentAddBrand.dictValue,
  184. sendFormId: this.orderId,
  185. })
  186. }
  187. }
  188. }
  189. </script>
  190. <style scoped>
  191. .slot-wrap {
  192. display: flex;
  193. align-items: center;
  194. background-color: #fff;
  195. border-radius: 40rpx;
  196. padding: 10rpx 20rpx;
  197. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  198. }
  199. .brand {
  200. font-weight: bold;
  201. color: #333;
  202. font-size: 28rpx;
  203. }
  204. .divider {
  205. margin: 0 15rpx;
  206. color: #ddd;
  207. font-size: 28rpx;
  208. }
  209. .model {
  210. color: #666;
  211. font-size: 26rpx;
  212. }
  213. .price {
  214. color: blueviolet;
  215. font-weight: bold;
  216. font-size: 28rpx;
  217. }
  218. .slot-right {
  219. display: flex;
  220. flex-direction: column;
  221. align-items: center;
  222. justify-content: center;
  223. font-size: 20rpx;
  224. color: blueviolet;
  225. image {
  226. width: 30rpx;
  227. height: 30rpx;
  228. }
  229. }
  230. </style>