index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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-tabs keyName="brand" :list="receiptList" @click="clickReceipt"></u-tabs>
  22. <orderDetailNewView :detail="receiptDetail" :topInfo="topInfo" :orderId="orderId"
  23. :currentReceipt="currentReceipt" />
  24. <!-- 加一单选择模态窗 -->
  25. <u-modal :show="addOneModelShow" :title="'加一单'" showCancelButton @cancel="addOneModelShow = false"
  26. @confirm="handleAddOneConfirm">
  27. <u-button type="primary" plain @click="showBrandSelector = true;"
  28. :text="currentAddBrand.dictLabel || '点击请选择品牌'"></u-button>
  29. </u-modal>
  30. <!-- 加一单品牌选择器 -->
  31. <u-picker :show="showBrandSelector" @confirm="handleBrandConfirm" :columns="brandColumns"
  32. @cancel='showBrandSelector = false' keyName="dictLabel"></u-picker>
  33. <!-- 修改当前品牌选择器 -->
  34. <u-picker :show="editBrandSelector" @confirm="handleEditBrandConfirm" :columns="brandColumns"
  35. @cancel='editBrandSelector = false' keyName="dictLabel"></u-picker>
  36. <!-- 修改当前型号、价格弹窗 -->
  37. <custom-modal :visible="modalVisible" :title="modalConfig.title" :value="modalConfig.value"
  38. :placeholder="modalConfig.placeholder" @cancel="handleModalCancel" @confirm="handleModalConfirm" />
  39. </view>
  40. </template>
  41. <script>
  42. import orderDetailNewView from './components/orderDetailNewView.vue'
  43. import CustomModal from './components/CustomModal.vue'
  44. export default {
  45. name: 'CustomNavbar',
  46. components: {
  47. orderDetailNewView,
  48. CustomModal
  49. },
  50. data() {
  51. return {
  52. topInfo: {
  53. brand: '',
  54. model: '',
  55. price: ''
  56. },
  57. currentEditField: '',
  58. modalConfig: {
  59. title: '',
  60. value: '',
  61. placeholder: ''
  62. },
  63. item: '',
  64. orderId: '',
  65. type: '',
  66. clueId: '',
  67. // 订单详情
  68. receiptDetail: {},
  69. //接单单个订单的receiptList
  70. receiptList: [],
  71. //当前选中的收单订单
  72. currentReceipt: {},
  73. // 新加一件的信息
  74. addOneModelShow: false,
  75. showBrandSelector: false,
  76. checkModel: {
  77. brand: '',
  78. },
  79. brandColumns: [
  80. []
  81. ],
  82. //当前选择的品牌
  83. currentAddBrand: {},
  84. //修改当前品牌选择器
  85. editBrandSelector: false,
  86. modalVisible: false,
  87. }
  88. },
  89. onLoad(option) {
  90. // 接收参数
  91. const { item, orderId, type, clueId } = option;
  92. console.log('接收的参数:', option);
  93. this.item = item;
  94. this.orderId = orderId;
  95. this.type = type;
  96. this.clueId = clueId;
  97. //查询订单详情
  98. this.getOrderDetail();
  99. //获取收单列表
  100. this.getReceiptList();
  101. },
  102. methods: {
  103. handleBrandClick() {
  104. //修改当前选中订单的品牌brand
  105. //打开品牌选择器
  106. this.editBrandSelector = true
  107. //获取品牌列表
  108. this.$getDicts('crm_form_brand').then(res => {
  109. this.brandColumns = [res]
  110. })
  111. },
  112. handleModelClick() {
  113. //修改当前选中订单的型号model
  114. //打开型号修改弹窗
  115. this.modalConfig = {
  116. title: '修改型号',
  117. value: this.currentReceipt.model,
  118. placeholder: '请输入型号'
  119. }
  120. this.currentEditField = 'model'
  121. this.modalVisible = true
  122. },
  123. handlePriceClick() {
  124. //修改当前选中订单的价格sellingPrice
  125. //打开价格修改弹窗
  126. this.modalConfig = {
  127. title: '修改价格',
  128. value: this.currentReceipt.sellingPrice?.toString(),
  129. placeholder: '请输入价格'
  130. }
  131. this.currentEditField = 'price'
  132. this.modalVisible = true
  133. },
  134. async handleModalConfirm(value) {
  135. console.log('修改的当前的', this.currentEditField, '是', value)
  136. if (this.currentEditField === 'model') {
  137. //修改当前选中receiptDetail的型号
  138. const res = await uni.$u.api.updateReceiptForm({
  139. model: value,
  140. id: this.currentReceipt.id
  141. });
  142. if (res.code == 200) {
  143. uni.$u.toast('修改成功')
  144. }
  145. } else if (this.currentEditField === 'price') {
  146. //修改当前选中receiptDetail的价格
  147. const res = await uni.$u.api.updateReceiptForm({
  148. sellingPrice: value,
  149. id: this.currentReceipt.id
  150. });
  151. if (res.code == 200) {
  152. uni.$u.toast('修改成功')
  153. }
  154. }
  155. this.getReceiptList();
  156. this.modalVisible = false
  157. },
  158. handleModalCancel() {
  159. this.modalVisible = false
  160. },
  161. async handleAddClick() {
  162. console.log('点击了加一单')
  163. //判断如果当前有收单的id是‘’的话,说明是新增的收单订单
  164. //打开模态窗
  165. //选择品牌,型号。价格
  166. this.addOneModelShow = true
  167. this.$getDicts('crm_form_brand').then(res => {
  168. console.log('品牌', res)
  169. this.brandColumns = [res]
  170. })
  171. },
  172. async handleEditBrandConfirm(data) {
  173. console.log('修改的当前的品牌是', data.value[0])
  174. console.log('修改的当前的品牌的value是', data.value[0].dictValue)
  175. //修改当前选中receiptDetail的品牌
  176. const res = await uni.$u.api.updateReceiptForm({
  177. brand: data.value[0].dictValue,
  178. id: this.currentReceipt.id
  179. });
  180. if (res.code === 200) {
  181. uni.$u.toast('修改成功')
  182. }
  183. this.getReceiptList();
  184. this.editBrandSelector = false
  185. },
  186. handleBrandConfirm(data) {
  187. console.log('选择的品牌', data.value[0])
  188. this.currentAddBrand = data.value[0]
  189. this.checkModel.brand = this.currentAddBrand.dictLabel
  190. //关闭品牌选择器
  191. this.showBrandSelector = false
  192. },
  193. //查询订单详情
  194. async getOrderDetail() {
  195. const res = await uni.$u.api
  196. .getClueSendFormVoByOrderId({
  197. id: this.orderId,
  198. })
  199. console.log('订单详情', res.data);
  200. if (res.code === 200) {
  201. this.receiptDetail = res.data;
  202. }
  203. },
  204. //获取收单列表
  205. async getReceiptList() {
  206. const res = await uni.$u.api.clueReceiptFormListByOrderId(this.orderId);
  207. console.log('这里是收件列表page', res)
  208. if (res.code === 200) {
  209. this.receiptList = res.data || [];
  210. }
  211. // this.currentReceipt = this.receiptList[0] || {};
  212. this.clickReceipt(this.receiptList[0])
  213. },
  214. clickReceipt(item) {
  215. // console.log('点击了', item);
  216. this.currentReceipt = item;
  217. console.log(item)
  218. this.topInfo.brand = item.brand || '暂无';
  219. this.topInfo.model = item.model || '暂无';
  220. this.topInfo.price = item.sellingPrice || '暂无';
  221. },
  222. async handleAddOneConfirm() {
  223. console.log('确认添加', this.currentAddBrand)
  224. //调新加一单的接口
  225. await uni.$u.api.addReceiptForm({
  226. brand: this.currentAddBrand.dictValue,
  227. sendFormId: this.orderId,
  228. clueId: this.clueId
  229. })
  230. //刷新收单列表
  231. this.getReceiptList();
  232. //关闭模态窗
  233. this.addOneModelShow = false
  234. }
  235. }
  236. }
  237. </script>
  238. <style scoped>
  239. .slot-wrap {
  240. display: flex;
  241. align-items: center;
  242. background-color: #fff;
  243. border-radius: 40rpx;
  244. padding: 10rpx 20rpx;
  245. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  246. }
  247. .brand {
  248. font-weight: bold;
  249. color: #333;
  250. font-size: 28rpx;
  251. }
  252. .divider {
  253. margin: 0 15rpx;
  254. color: #ddd;
  255. font-size: 28rpx;
  256. }
  257. .model {
  258. color: #666;
  259. font-size: 26rpx;
  260. }
  261. .price {
  262. color: blueviolet;
  263. font-weight: bold;
  264. font-size: 28rpx;
  265. }
  266. .slot-right {
  267. display: flex;
  268. flex-direction: column;
  269. align-items: center;
  270. justify-content: center;
  271. font-size: 20rpx;
  272. color: blueviolet;
  273. image {
  274. width: 30rpx;
  275. height: 30rpx;
  276. }
  277. }
  278. </style>