index.vue 9.8 KB

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