混凝土运输管理微信小程序、替班
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

356 lines
8.0 KiB

2 weeks ago
  1. <template>
  2. <view class="content">
  3. <navbar title="发布订单" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="form-container">
  5. <!-- 项目名称 -->
  6. <view class="form-item">
  7. <view class="label">项目名称</view>
  8. <input
  9. v-model="orderInfo.projectName"
  10. placeholder="请输入项目名称"
  11. class="input"
  12. />
  13. </view>
  14. <!-- 工作地址 -->
  15. <view class="form-item">
  16. <view class="label">工作地址</view>
  17. <view class="address-input" @click="selectAddress">
  18. <text v-if="!orderInfo.workAddress" class="placeholder">请选择工作地址</text>
  19. <text v-else>{{ orderInfo.workAddress }}</text>
  20. <uv-icon name="map-pin" size="20" color="#007AFF"></uv-icon>
  21. </view>
  22. </view>
  23. <!-- 服务类型 -->
  24. <view class="form-item">
  25. <view class="label">服务类型</view>
  26. <view class="select-value" @click="selectServiceType">
  27. <text v-if="!orderInfo.serviceType" class="placeholder">请选择服务类型</text>
  28. <text v-else>{{ orderInfo.serviceType }}</text>
  29. <uv-icon name="arrow-right" size="16" color="#999"></uv-icon>
  30. </view>
  31. </view>
  32. <!-- 工作时间 -->
  33. <view class="form-item">
  34. <view class="label">工作时间</view>
  35. <view class="time-container">
  36. <view class="time-item" @click="selectStartTime">
  37. <text v-if="!orderInfo.startTime" class="placeholder">开始时间</text>
  38. <text v-else>{{ orderInfo.startTime }}</text>
  39. </view>
  40. <text class="time-separator"></text>
  41. <view class="time-item" @click="selectEndTime">
  42. <text v-if="!orderInfo.endTime" class="placeholder">结束时间</text>
  43. <text v-else>{{ orderInfo.endTime }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 混凝土方量 -->
  48. <view class="form-item">
  49. <view class="label">混凝土方量(m³)</view>
  50. <input
  51. v-model="orderInfo.volume"
  52. placeholder="请输入混凝土方量"
  53. class="input"
  54. type="number"
  55. />
  56. </view>
  57. <!-- 预计趟数 -->
  58. <view class="form-item">
  59. <view class="label">预计趟数</view>
  60. <input
  61. v-model="orderInfo.tripCount"
  62. placeholder="请输入预计趟数"
  63. class="input"
  64. type="number"
  65. />
  66. </view>
  67. <!-- 单价 -->
  68. <view class="form-item">
  69. <view class="label">单价(/)</view>
  70. <input
  71. v-model="orderInfo.unitPrice"
  72. placeholder="请输入单价"
  73. class="input"
  74. type="number"
  75. />
  76. </view>
  77. <!-- 联系人 -->
  78. <view class="form-item">
  79. <view class="label">联系人</view>
  80. <input
  81. v-model="orderInfo.contactName"
  82. placeholder="请输入联系人姓名"
  83. class="input"
  84. />
  85. </view>
  86. <!-- 联系电话 -->
  87. <view class="form-item">
  88. <view class="label">联系电话</view>
  89. <input
  90. v-model="orderInfo.contactPhone"
  91. placeholder="请输入联系电话"
  92. class="input"
  93. type="number"
  94. maxlength="11"
  95. />
  96. </view>
  97. <!-- 备注 -->
  98. <view class="form-item">
  99. <view class="label">备注</view>
  100. <textarea
  101. v-model="orderInfo.remark"
  102. placeholder="请输入备注信息"
  103. class="textarea"
  104. maxlength="200"
  105. ></textarea>
  106. </view>
  107. </view>
  108. <!-- 底部按钮 -->
  109. <view class="bottom-buttons">
  110. <button class="btn-save" @click="saveOrder">发布订单</button>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import navbar from '@/components/base/navbar.vue'
  116. export default {
  117. name: 'StaffCreate',
  118. components: {
  119. navbar
  120. },
  121. data() {
  122. return {
  123. orderInfo: {
  124. projectName: '',
  125. workAddress: '',
  126. serviceType: '',
  127. startTime: '',
  128. endTime: '',
  129. volume: '',
  130. tripCount: '',
  131. unitPrice: '',
  132. contactName: '',
  133. contactPhone: '',
  134. remark: ''
  135. }
  136. }
  137. },
  138. onLoad() {
  139. uni.setNavigationBarTitle({
  140. title: '发布订单'
  141. });
  142. },
  143. methods: {
  144. selectAddress() {
  145. uni.chooseLocation({
  146. success: (res) => {
  147. this.orderInfo.workAddress = res.address;
  148. }
  149. });
  150. },
  151. selectServiceType() {
  152. uni.showActionSheet({
  153. itemList: ['泵车代驾', '搅拌车代驾', '车载泵代驾'],
  154. success: (res) => {
  155. const types = ['泵车代驾', '搅拌车代驾', '车载泵代驾'];
  156. this.orderInfo.serviceType = types[res.tapIndex];
  157. }
  158. });
  159. },
  160. selectStartTime() {
  161. uni.showModal({
  162. title: '选择开始时间',
  163. content: '请在日期时间选择器中选择开始时间',
  164. success: (res) => {
  165. if (res.confirm) {
  166. // 模拟选择时间
  167. const now = new Date();
  168. this.orderInfo.startTime = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} 08:00`;
  169. }
  170. }
  171. });
  172. },
  173. selectEndTime() {
  174. uni.showModal({
  175. title: '选择结束时间',
  176. content: '请在日期时间选择器中选择结束时间',
  177. success: (res) => {
  178. if (res.confirm) {
  179. // 模拟选择时间
  180. const now = new Date();
  181. this.orderInfo.endTime = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')} 18:00`;
  182. }
  183. }
  184. });
  185. },
  186. saveOrder() {
  187. // 表单验证
  188. if (!this.orderInfo.projectName) {
  189. uni.showToast({ title: '请输入项目名称', icon: 'none' });
  190. return;
  191. }
  192. if (!this.orderInfo.workAddress) {
  193. uni.showToast({ title: '请选择工作地址', icon: 'none' });
  194. return;
  195. }
  196. if (!this.orderInfo.serviceType) {
  197. uni.showToast({ title: '请选择服务类型', icon: 'none' });
  198. return;
  199. }
  200. if (!this.orderInfo.startTime || !this.orderInfo.endTime) {
  201. uni.showToast({ title: '请选择工作时间', icon: 'none' });
  202. return;
  203. }
  204. if (!this.orderInfo.contactName) {
  205. uni.showToast({ title: '请输入联系人', icon: 'none' });
  206. return;
  207. }
  208. if (!this.orderInfo.contactPhone) {
  209. uni.showToast({ title: '请输入联系电话', icon: 'none' });
  210. return;
  211. }
  212. uni.showToast({
  213. title: '发布成功',
  214. icon: 'success'
  215. });
  216. setTimeout(() => {
  217. uni.navigateBack();
  218. }, 1500);
  219. }
  220. }
  221. }
  222. </script>
  223. <style scoped lang="scss">
  224. .content {
  225. padding: 20rpx;
  226. min-height: 100vh;
  227. background-color: #f5f5f5;
  228. padding-bottom: 120rpx;
  229. }
  230. .form-container {
  231. background-color: #fff;
  232. border-radius: 10rpx;
  233. padding: 30rpx;
  234. }
  235. .form-item {
  236. margin-bottom: 40rpx;
  237. &:last-child {
  238. margin-bottom: 0;
  239. }
  240. }
  241. .label {
  242. font-size: 28rpx;
  243. color: #333;
  244. margin-bottom: 20rpx;
  245. font-weight: 500;
  246. }
  247. .input {
  248. width: 100%;
  249. height: 80rpx;
  250. padding: 0 20rpx;
  251. border: 1rpx solid #e0e0e0;
  252. border-radius: 8rpx;
  253. font-size: 28rpx;
  254. box-sizing: border-box;
  255. }
  256. .textarea {
  257. width: 100%;
  258. height: 120rpx;
  259. padding: 20rpx;
  260. border: 1rpx solid #e0e0e0;
  261. border-radius: 8rpx;
  262. font-size: 28rpx;
  263. box-sizing: border-box;
  264. resize: none;
  265. }
  266. .select-value {
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. height: 80rpx;
  271. padding: 0 20rpx;
  272. border: 1rpx solid #e0e0e0;
  273. border-radius: 8rpx;
  274. font-size: 28rpx;
  275. }
  276. .address-input {
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. height: 80rpx;
  281. padding: 0 20rpx;
  282. border: 1rpx solid #e0e0e0;
  283. border-radius: 8rpx;
  284. font-size: 28rpx;
  285. }
  286. .time-container {
  287. display: flex;
  288. align-items: center;
  289. gap: 20rpx;
  290. }
  291. .time-item {
  292. flex: 1;
  293. height: 80rpx;
  294. padding: 0 20rpx;
  295. border: 1rpx solid #e0e0e0;
  296. border-radius: 8rpx;
  297. font-size: 28rpx;
  298. display: flex;
  299. align-items: center;
  300. }
  301. .time-separator {
  302. font-size: 28rpx;
  303. color: #666;
  304. }
  305. .placeholder {
  306. color: #999;
  307. }
  308. .bottom-buttons {
  309. position: fixed;
  310. bottom: 0;
  311. left: 0;
  312. right: 0;
  313. padding: 20rpx;
  314. background-color: #fff;
  315. border-top: 1rpx solid #f0f0f0;
  316. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  317. }
  318. .btn-save {
  319. width: 100%;
  320. height: 80rpx;
  321. line-height: 80rpx;
  322. background-color: #007AFF;
  323. color: #fff;
  324. border-radius: 40rpx;
  325. font-size: 32rpx;
  326. border: none;
  327. }
  328. </style>