auxiliarySalesOrderDetail.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. <template>
  2. <div class="s-page">
  3. <el-page-header @back="goBack" :content="title"></el-page-header>
  4. <el-divider></el-divider>
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>单据信息</span>
  8. </div>
  9. <div class="mymain-container">
  10. <el-form ref="formData" :rules="rules" :model="formData" label-width="110px" size="small" label-position="left">
  11. <el-row :gutter="20" justify="start">
  12. <el-col :span="8" v-if="id">
  13. <el-form-item label="单据状态">
  14. <el-input
  15. type="text"
  16. :value="
  17. formData.flag == 'SAVE'
  18. ? '已保存'
  19. : formData.flag == 'SUBMIT'
  20. ? '已提交'
  21. : formData.flag == 'CANCEL'
  22. ? '取消订单'
  23. : formData.flag == 'PAY_NOT_TAKE'
  24. ? '已支付,未提货'
  25. : formData.flag == 'PAY_TAKE'
  26. ? '已支付,已提货'
  27. : ''
  28. "
  29. disabled
  30. ></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="8" v-if="id">
  34. <el-form-item label="单据编号">
  35. <el-input type="text" :value="formData.salesId" disabled></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="16">
  39. <el-form-item label="网点名称" prop="websitId">
  40. <el-select
  41. v-model="formData.websit"
  42. :disabled="formData.flag != 'SAVE' && formType != 0"
  43. value-key="websitId"
  44. @change="changeWebsit"
  45. placeholder="请选择"
  46. style="width: 100%"
  47. >
  48. <el-option
  49. v-for="item in websitList"
  50. :key="item.websitId"
  51. :label="`(${item.websitId})${item.name}`"
  52. :value="item"
  53. >
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="购买方" :required="true" style="padding-bottom: 1px">
  60. <el-radio-group
  61. v-model="formData.buyPeople"
  62. @change="
  63. formData.workerName = ''
  64. formData.workerMobile = ''
  65. "
  66. >
  67. <el-radio
  68. :disabled="(formData.flag != 'SAVE' && formType != 0) || formData.salesType == '工程'"
  69. label="WORKER"
  70. >内部师傅</el-radio
  71. >
  72. <el-radio
  73. :disabled="(formData.flag != 'SAVE' && formType != 0) || formData.salesType == '工程'"
  74. label="CUSTOMER"
  75. >客户</el-radio
  76. >
  77. </el-radio-group>
  78. </el-form-item>
  79. </el-col>
  80. <template v-if="formData.buyPeople == 'CUSTOMER'">
  81. <el-col :span="8">
  82. <el-form-item label="客户姓名" prop="workerName">
  83. <el-input
  84. type="text"
  85. :disabled="formData.flag != 'SAVE' && formType != 0"
  86. v-model="formData.workerName"
  87. placeholder="请输入"
  88. ></el-input>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="客户联系电话" prop="workerMobile">
  93. <el-input
  94. type="text"
  95. :disabled="formData.flag != 'SAVE' && formType != 0"
  96. v-model="formData.workerMobile"
  97. placeholder="请输入"
  98. ></el-input>
  99. </el-form-item>
  100. </el-col>
  101. </template>
  102. <template v-else>
  103. <el-col :span="8">
  104. <el-form-item label="师傅姓名" prop="worker">
  105. <el-select
  106. v-model="formData.worker"
  107. :disabled="formData.flag != 'SAVE' && formType != 0"
  108. value-key="nickName"
  109. @focus="
  110. () => {
  111. if (!this.formData.websitId) {
  112. return this.$message.warning('请先选择网点名称!')
  113. }
  114. }
  115. "
  116. filterable
  117. @change="changeWorker"
  118. @blur="workerBlur"
  119. placeholder="请选择"
  120. style="width: 100%"
  121. >
  122. <el-option
  123. v-for="item in workerList"
  124. :key="item.workerNumber"
  125. :label="item.nickName + '-' + item.mobile"
  126. :value="item"
  127. >
  128. </el-option>
  129. </el-select>
  130. </el-form-item>
  131. </el-col>
  132. <!-- <el-col :span="8">
  133. <el-form-item label="师傅身份证" prop="identity" :required="true">
  134. <el-input type="text" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.identity" placeholder="请输入"></el-input>
  135. </el-form-item>
  136. </el-col> -->
  137. <el-col :span="8">
  138. <el-form-item label="师傅联系电话" prop="workerMobile">
  139. <el-input
  140. type="text"
  141. :disabled="formData.flag != 'SAVE' && formType != 0"
  142. v-model="formData.workerMobile"
  143. placeholder="请输入"
  144. ></el-input>
  145. </el-form-item>
  146. </el-col>
  147. </template>
  148. <!-- <el-col :span="8">
  149. <el-form-item label="销售类型" :required="true" style="padding-bottom: 1px">
  150. <el-radio-group v-model="formData.salesType" @change="changeSale">
  151. <el-radio :disabled="formData.flag != 'SAVE' && formType != 0" label="零售">零售</el-radio>
  152. <el-radio :disabled="formData.flag != 'SAVE' && formType != 0" label="工程">工程</el-radio>
  153. </el-radio-group>
  154. </el-form-item>
  155. </el-col> -->
  156. <el-col :span="8" v-if="id">
  157. <el-form-item label="单据金额">
  158. <el-input type="text" :value="formData.totalAmount" disabled></el-input>
  159. </el-form-item>
  160. </el-col>
  161. <el-col :span="8">
  162. <el-form-item label="订单来源" prop="orderSource" :required="true">
  163. <el-select v-model="formData.orderSource" :disabled="true" placeholder="请选择" style="width: 100%">
  164. <el-option
  165. v-for="item in [
  166. { name: '在线订单', id: 'ONLINE' },
  167. { name: '自建订单', id: 'SELF' }
  168. ]"
  169. :key="item.id"
  170. :label="item.name"
  171. :value="item.id"
  172. >
  173. </el-option>
  174. </el-select>
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="6">
  178. <el-form-item label="支付方式" prop="payType" :required="true">
  179. <el-radio-group v-model="formData.payType">
  180. <el-radio :disabled="formData.flag != 'SAVE' && formType != 0" label="CASH">现金</el-radio>
  181. <el-radio :disabled="formData.flag != 'SAVE' && formType != 0" label="ALLINPAY">通联支付</el-radio>
  182. <el-radio
  183. v-if="formData.salesType == '工程'"
  184. :disabled="formData.flag != 'SAVE' && formType != 0"
  185. label="ENGIN"
  186. >工程支付</el-radio
  187. >
  188. </el-radio-group>
  189. </el-form-item>
  190. </el-col>
  191. <el-col :span="2" v-if="formData.flag == 'SUBMIT' && formData.payType == 'ALLINPAY'">
  192. <div style="height: 32px; display: flex; align-items: center; cursor: pointer" @click="wxPay()">
  193. 通联支付<i class="el-icon-full-screen"></i>
  194. </div>
  195. </el-col>
  196. <el-col :span="2" v-else>
  197. <div style="opacity: 0">隐藏</div>
  198. </el-col>
  199. <el-col :span="6">
  200. <el-form-item label="出库仓库" prop="storage">
  201. <el-select
  202. v-model="formData.storage"
  203. value-key="storageId"
  204. @focus="
  205. () => {
  206. if (!this.formData.websitId) {
  207. return this.$message.warning('请先选择网点名称!')
  208. }
  209. }
  210. "
  211. @change="changeStorage"
  212. :disabled="
  213. (['SAVE', 'PAY_NOT_TAKE'].indexOf(formData.flag) == -1 && formData.orderSource == 'ONLINE') ||
  214. (formType != 0 && ['SAVE', 'PAY_NOT_TAKE'].indexOf(formData.flag) == -1)
  215. "
  216. placeholder="请选择"
  217. style="width: 100%"
  218. >
  219. <el-option
  220. v-for="(item, index) in warehouseList"
  221. :key="index"
  222. :label="item.storageName"
  223. :value="item"
  224. >
  225. </el-option>
  226. </el-select>
  227. </el-form-item>
  228. </el-col>
  229. <template v-if="formData.salesType == '工程'">
  230. <el-col :span="8">
  231. <el-form-item label="工程名称" prop="project" :required="true">
  232. <div style="display: flex; align-items: center">
  233. <el-select
  234. v-model="formData.project"
  235. value-key="id"
  236. @change="
  237. e => {
  238. formData.orderEnginBaseId = e.id
  239. }
  240. "
  241. :disabled="formData.flag != 'SAVE' && formType != 0"
  242. placeholder="请选择"
  243. style="width: 100%"
  244. >
  245. <el-option
  246. v-for="(item, index) in projectList"
  247. :key="index"
  248. :label="item.projectName"
  249. :value="item"
  250. >
  251. </el-option>
  252. </el-select>
  253. <i
  254. class="el-icon-circle-plus"
  255. @click="toAddProject"
  256. style="transform: scale(1.5); color: #1989fa; margin-left: 10px; cursor: pointer"
  257. ></i>
  258. </div>
  259. </el-form-item>
  260. </el-col>
  261. <el-col :span="6">
  262. <el-form-item label="工程编号" :required="true">
  263. <el-input
  264. type="text"
  265. :disabled="true"
  266. v-model="formData.project.projectNo"
  267. placeholder="请输入"
  268. ></el-input>
  269. </el-form-item>
  270. </el-col>
  271. <el-col :span="6">
  272. <el-form-item label="负责人" :required="true">
  273. <el-input
  274. type="text"
  275. :disabled="true"
  276. v-model="formData.project.manger"
  277. placeholder="请输入"
  278. ></el-input>
  279. </el-form-item>
  280. </el-col>
  281. <el-col :span="6">
  282. <el-form-item label="联系电话" :required="true">
  283. <el-input
  284. type="text"
  285. :disabled="true"
  286. v-model="formData.project.mobile"
  287. placeholder="请输入"
  288. ></el-input>
  289. </el-form-item>
  290. </el-col>
  291. <el-col :span="6">
  292. <el-form-item label="项目时间" :required="true">
  293. <el-date-picker
  294. style="width: 50%"
  295. v-model="formData.project.startTime"
  296. type="date"
  297. :disabled="true"
  298. value-format="yyyy-MM-dd"
  299. placeholder="开始日期"
  300. >
  301. </el-date-picker>
  302. <el-date-picker
  303. style="width: 50%"
  304. v-model="formData.project.endTime"
  305. type="date"
  306. :disabled="true"
  307. value-format="yyyy-MM-dd"
  308. placeholder="结束日期"
  309. >
  310. </el-date-picker>
  311. </el-form-item>
  312. </el-col>
  313. <el-col :span="24">
  314. <el-form-item label="项目地址" :required="true">
  315. <el-row>
  316. <el-col :span="5" style="margin-right: 12px">
  317. <el-input
  318. type="text"
  319. v-model="formData.project.province"
  320. disabled
  321. placeholder="请选择省"
  322. ></el-input>
  323. </el-col>
  324. <el-col :span="5" style="margin-right: 12px">
  325. <el-input type="text" v-model="formData.project.city" disabled placeholder="请选择市"></el-input>
  326. </el-col>
  327. <el-col :span="5" style="margin-right: 12px">
  328. <el-input type="text" v-model="formData.project.area" disabled placeholder="请选择区"></el-input>
  329. </el-col>
  330. <el-col :span="8">
  331. <el-input
  332. type="text"
  333. v-model="formData.project.street"
  334. disabled
  335. placeholder="请选择街道"
  336. ></el-input>
  337. </el-col>
  338. </el-row>
  339. </el-form-item>
  340. </el-col>
  341. <el-col :span="24">
  342. <el-form-item label="">
  343. <el-row :gutter="20">
  344. <el-col :span="24">
  345. <el-input
  346. type="text"
  347. v-model="formData.project.address"
  348. :disabled="true"
  349. placeholder="详细地址"
  350. ></el-input>
  351. </el-col>
  352. <!-- <el-col :span="2">
  353. <geographicalPosi :disabled="formType==2" :formData="this.formData" @selectPosi="selectAddress"/>
  354. </el-col> -->
  355. </el-row>
  356. </el-form-item>
  357. </el-col>
  358. </template>
  359. <el-col :span="6" v-if="id">
  360. <el-form-item label="制单人">
  361. <el-input type="text" :value="formData.createBy" disabled></el-input>
  362. </el-form-item>
  363. </el-col>
  364. <el-col :span="6" v-if="id">
  365. <el-form-item label="制单时间">
  366. <el-input type="text" :value="formData.createTime" disabled></el-input>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="6" v-if="id">
  370. <el-form-item label="审核人">
  371. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  372. </el-form-item>
  373. </el-col>
  374. <el-col :span="6" v-if="id">
  375. <el-form-item label="审核时间">
  376. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  377. </el-form-item>
  378. </el-col>
  379. <el-col :span="24">
  380. <el-form-item label="备注">
  381. <el-input
  382. type="textarea"
  383. :rows="4"
  384. :disabled="formData.flag != 'SAVE' && formType != 0"
  385. v-model="formData.remark"
  386. placeholder="请输入"
  387. ></el-input>
  388. </el-form-item>
  389. </el-col>
  390. </el-row>
  391. </el-form>
  392. </div>
  393. </el-card>
  394. <el-card class="box-card">
  395. <div slot="header" class="clearfix">
  396. <span>辅材信息</span>
  397. </div>
  398. <el-button size="small" v-if="formData.flag == 'SAVE' || formType == 0" type="primary" @click="add()"
  399. >添加</el-button
  400. >
  401. <div class="table">
  402. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  403. <el-table-column label="大类名称" align="center">
  404. <template slot-scope="scope">
  405. <el-select
  406. v-model="scope.row.parentCategory"
  407. value-key="categoryId"
  408. @change="changeMain"
  409. :disabled="isEdit != scope.$index || formType == 2"
  410. placeholder="请选择"
  411. style="width: 100%"
  412. >
  413. <el-option v-for="item in mainList" :key="item.categoryId" :label="item.categoryName" :value="item">
  414. </el-option>
  415. </el-select>
  416. </template>
  417. </el-table-column>
  418. <el-table-column label="小类名称" align="center">
  419. <template slot-scope="scope">
  420. <el-select
  421. v-model="scope.row.goodsCategory"
  422. @change="changeSmall"
  423. @focus="
  424. () => {
  425. if (!scope.row.parentCategory) {
  426. return this.$message.warning('请先选择大类!')
  427. }
  428. }
  429. "
  430. :disabled="isEdit != scope.$index || formType == 2"
  431. value-key="categoryId"
  432. placeholder="请选择"
  433. style="width: 100%"
  434. >
  435. <el-option
  436. v-for="item in scope.row.parentCategory.items"
  437. :key="item.categoryId"
  438. :label="item.categoryName"
  439. :value="item"
  440. >
  441. </el-option>
  442. </el-select>
  443. </template>
  444. </el-table-column>
  445. <el-table-column label="辅材名称" align="center" width="220px">
  446. <template slot-scope="scope">
  447. <el-select
  448. v-model="scope.row.goods"
  449. @change="changeGoods"
  450. value-key="goodsId"
  451. :disabled="isEdit != scope.$index || formType == 2"
  452. placeholder="请选择"
  453. style="width: 100%"
  454. >
  455. <el-option
  456. v-for="item in scope.row.goodsList"
  457. :key="item.goodsId"
  458. :label="item.goodsName"
  459. :value="item"
  460. >
  461. </el-option>
  462. </el-select>
  463. </template>
  464. </el-table-column>
  465. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位"></el-table-column>
  466. <el-table-column prop="" align="center" label="数量">
  467. <template slot-scope="scope">
  468. <el-input
  469. type="number"
  470. v-model="scope.row.salesQty"
  471. :disabled="isEdit != scope.$index || formType == 2"
  472. placeholder="请输入"
  473. ></el-input>
  474. </template>
  475. </el-table-column>
  476. <el-table-column prop="goods.goodsCode" align="center" label="辅材代码"></el-table-column>
  477. <el-table-column prop="goods.goodsSpecification" align="center" label="规格型号"></el-table-column>
  478. <el-table-column prop="" align="center" label="销售价格">
  479. <template slot-scope="scope">
  480. <el-input
  481. type="number"
  482. v-model="scope.row.price"
  483. :disabled="isEdit != scope.$index || formType == 2"
  484. placeholder="请输入"
  485. ></el-input>
  486. </template>
  487. </el-table-column>
  488. <el-table-column prop="" align="center" label="销售金额">
  489. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.price">
  490. {{ ((scope.row.price * 100 * scope.row.salesQty) / 100).toFixed(2) }}
  491. </template>
  492. </el-table-column>
  493. <el-table-column prop="goods.qty" align="center" label="全部库存数量"></el-table-column>
  494. <el-table-column label="操作" align="right" width="140">
  495. <template slot-scope="scope" v-if="formType != 2">
  496. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index"
  497. >编辑</el-button
  498. >
  499. <el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
  500. </template>
  501. </el-table-column>
  502. </el-table>
  503. </div>
  504. </el-card>
  505. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0 && formData.flag == 'SAVE'">
  506. <div slot="header" class="clearfix">
  507. <span>收款信息</span>
  508. </div>
  509. <div class="mymain-container">
  510. <el-form
  511. ref="formData1"
  512. :rules="rules1"
  513. :model="formData1"
  514. label-width="110px"
  515. size="small"
  516. label-position="left"
  517. >
  518. <el-row :gutter="20" justify="start">
  519. <el-col :span="24">
  520. <el-form-item label="收款金额" prop="price">
  521. <el-input type="text" style="width: 30%" v-model="formData1.price" placeholder="请输入"></el-input>
  522. <span style="color: #ff8f47; margin-left: 10px">注:操作【提交】时,系统方可记录收款信息</span>
  523. </el-form-item>
  524. </el-col>
  525. <el-col :span="24">
  526. <el-form-item label="收款凭证">
  527. <ImageUpload :fileList="formData1.fileUrl" :limit="1" :isEdit="formType !== 2" />
  528. </el-form-item>
  529. </el-col>
  530. <el-col :span="24">
  531. <el-form-item label="备注">
  532. <el-input type="textarea" :rows="4" v-model="formData1.remark" placeholder="请输入"></el-input>
  533. </el-form-item>
  534. </el-col>
  535. </el-row>
  536. </el-form>
  537. </div>
  538. </el-card>
  539. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0">
  540. <div slot="header" class="clearfix">
  541. <span>收款记录</span>
  542. </div>
  543. <div class="table">
  544. <el-table :data="collectionList" element-loading-text="Loading" border fit highlight-current-row stripe>
  545. <el-table-column prop="status" label="收款结果" align="center">
  546. <template slot-scope="scope">
  547. {{
  548. scope.row.status == 'NO'
  549. ? '未付款'
  550. : scope.row.status == 'WAIT'
  551. ? '部分付款'
  552. : scope.row.status == 'OK'
  553. ? '已完成'
  554. : ''
  555. }}
  556. </template>
  557. </el-table-column>
  558. <el-table-column prop="price" label="收款金额" align="center"></el-table-column>
  559. <el-table-column prop="" align="center" label="收款凭证">
  560. <template slot-scope="scope" v-if="scope.row.urlPrc">
  561. <el-image
  562. style="width: 80px"
  563. :src="$showImgUrl(scope.row.urlPrc)"
  564. fit="scale-down"
  565. :preview-src-list="[$showImgUrl(scope.row.urlPrc)]"
  566. ></el-image>
  567. </template>
  568. </el-table-column>
  569. <el-table-column prop="remark" label="备注" align="center"></el-table-column>
  570. <el-table-column prop="updateBy" align="center" label="收款人"></el-table-column>
  571. <el-table-column prop="updateTime" align="center" label="收款时间"></el-table-column>
  572. </el-table>
  573. </div>
  574. </el-card>
  575. <div class="page-footer">
  576. <div class="footer">
  577. <el-button
  578. v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')"
  579. size="small"
  580. type="primary"
  581. @click="save()"
  582. >保存</el-button
  583. >
  584. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()"
  585. >提交</el-button
  586. >
  587. <el-button
  588. v-if="formData.flag == 'SUBMIT' && formData.payType == 'ALLINPAY'"
  589. size="small"
  590. type="primary"
  591. @click="wxPay()"
  592. >通联支付</el-button
  593. >
  594. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()"
  595. >确认提货</el-button
  596. >
  597. <el-button size="small" type="info" @click="goBack">返回</el-button>
  598. </div>
  599. </div>
  600. <el-dialog
  601. title="微信支付"
  602. :visible.sync="isPay"
  603. width="50%"
  604. :close-on-click-modal="false"
  605. :modal-append-to-body="false"
  606. @close="
  607. payCodeUrl = ''
  608. clear()
  609. "
  610. >
  611. <h3 style="text-align: center">扫二维码支付</h3>
  612. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  613. <div ref="payQRCode" style="display: flex; justify-content: center" />
  614. <div style="color: #ea8000; text-align: center; margin-top: 20px">注:支付成功后,方可操作确认提货!</div>
  615. <div style="display: flex; justify-content: flex-end; margin-top: 30px">
  616. <el-button
  617. size="mini"
  618. type="text"
  619. @click="
  620. isPay = false
  621. clear()
  622. "
  623. >取消</el-button
  624. >
  625. <el-button
  626. size="small"
  627. type="primary"
  628. @click="
  629. isPay = false
  630. getDetail()
  631. "
  632. >确定</el-button
  633. >
  634. </div>
  635. </el-dialog>
  636. </div>
  637. </template>
  638. <script>
  639. import { getWebsit } from '@/api/customerManagement'
  640. import QRCode from 'qrcodejs2'
  641. import { lbsAmapRegion, adminWebsitPayConfigList } from '@/api/common.js'
  642. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  643. import ImageUpload from '@/components/file-upload'
  644. import {
  645. getWorker,
  646. getCategory,
  647. getGoods,
  648. getDetail,
  649. add,
  650. edit,
  651. confirm,
  652. submit,
  653. getCode,
  654. getProject,
  655. getProjectCollectionList
  656. } from '@/api/auxiliaryFittings/auxiliarySalesOrder'
  657. import { storageListPageV2 } from '@/api/storage.js'
  658. import selectEl from '@/utils/xialaxuanz.js'
  659. export default {
  660. components: { geographicalPosi, ImageUpload },
  661. props: ['id', 'title', 'formType'],
  662. data() {
  663. return {
  664. dataList: [],
  665. websitList: [],
  666. workerList: [],
  667. mainList: [],
  668. projectList: [],
  669. collectionList: [],
  670. warehouseList: [],
  671. isPay: false,
  672. payCodeUrl: '',
  673. formData: {
  674. websit: {},
  675. websitId: '',
  676. websitName: '',
  677. file_url: [],
  678. salesId: '',
  679. flag: '',
  680. createBy: '',
  681. createTime: '',
  682. confirmBy: '',
  683. confirmTime: '',
  684. worker: {},
  685. workerName: '',
  686. workerId: '',
  687. identity: '',
  688. workerMobile: '',
  689. orderSource: 'SELF',
  690. payType: '',
  691. remark: '',
  692. totalAmount: '',
  693. buyPeople: 'WORKER',
  694. salesType: '零售',
  695. province: '',
  696. provinceId: '',
  697. city: '',
  698. cityId: '',
  699. area: '',
  700. areaId: '',
  701. street: '',
  702. streetId: '',
  703. address: '',
  704. lat: '',
  705. lng: '',
  706. project: {},
  707. orderEnginBaseId: '',
  708. storage: null,
  709. storageId: '',
  710. storageName: ''
  711. },
  712. formData1: {
  713. price: '',
  714. remark: '',
  715. fileUrl: []
  716. },
  717. provinceList: [],
  718. cityList: [],
  719. areaList: [],
  720. streetList: [],
  721. isEdit: 0,
  722. is_submit: true,
  723. timer: '',
  724. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  725. rules: {
  726. websitId: [{ required: true, message: '请选择网点', trigger: 'change' }],
  727. worker: [{ required: true, message: '请选择师傅', trigger: 'change' }],
  728. orderSource: [{ required: true, message: '请选择订单来源', trigger: 'change' }],
  729. payType: [{ required: true, message: '请选择订单来源', trigger: 'change' }],
  730. identity: [
  731. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  732. { pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  733. ],
  734. workerMobile: [
  735. { required: true, message: `请输入联系电话`, trigger: 'blur' },
  736. { required: true, message: `请输入联系电话`, trigger: 'change' },
  737. { pattern: /^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  738. ],
  739. workerName: [{ required: true, message: '请输入客户姓名', trigger: 'blur' }],
  740. storage: [{ required: true, message: `请选择入库仓库`, trigger: 'change' }]
  741. },
  742. rules1: {
  743. price: [{ pattern: /^[1-9]\d*(\.\d+)?$|^0\.[1-9]\d*$/, message: '请输入大于0的数字', trigger: 'blur' }]
  744. }
  745. }
  746. },
  747. computed: {},
  748. created() {
  749. if (this.id) {
  750. this.getDetail()
  751. }
  752. this.getinitlbslist()
  753. this.getWebsit()
  754. this.getProject()
  755. },
  756. mounted() {},
  757. methods: {
  758. // 返回
  759. goBack() {
  760. this.$emit('back')
  761. },
  762. async getDetail() {
  763. const that = this
  764. getDetail({ salesId: this.id }).then(async res => {
  765. Object.assign(this.formData, res.data, {
  766. websit: { websitId: res.data.websitId, name: res.data.websitName },
  767. worker: { nickName: res.data.workerName, userId: res.data.workerId },
  768. project: {
  769. id: res.data.orderEnginBaseId,
  770. projectName: res.data.projectName,
  771. projectNo: res.data.projectNo,
  772. manger: res.data.manger,
  773. mobile: res.data.mobile,
  774. startTime: res.data.startTime,
  775. endTime: res.data.endTime,
  776. province: res.data.province,
  777. provinceId: res.data.provinceId,
  778. city: res.data.city,
  779. cityId: res.data.cityId,
  780. area: res.data.area,
  781. areaId: res.data.areaId,
  782. street: res.data.street,
  783. streetId: res.data.streetId,
  784. address: res.data.address,
  785. lat: res.data.lat,
  786. lng: res.data.lng
  787. },
  788. storage: {
  789. storageId: res.data.storageId
  790. }
  791. })
  792. this.getWorker()
  793. this.getCategory(res.data.websitId, res.data.storageId)
  794. this.getWarehouseList(res.data.websitId)
  795. if (res.data.salesType == '工程') {
  796. this.getProjectCollectionList(res.data.orderEnginBaseId)
  797. }
  798. this.formData.remark = res.data.remark
  799. for (var item of res.data.items) {
  800. item.parentCategory = {
  801. categoryId: item.parentCategoryId,
  802. categoryName: item.parentCategoryName,
  803. items: [{ categoryId: item.goodsCategoryId, categoryName: item.goodsCategoryName }]
  804. }
  805. item.goodsCategory = { categoryId: item.goodsCategoryId, categoryName: item.goodsCategoryName }
  806. var ress = await that.getGoods(item.goodsCategoryId, item.goodsName, 1)
  807. item.goods = ress.data
  808. item.goodsList = ress.data ? [ress.data] : []
  809. }
  810. this.dataList = res.data.items
  811. console.log(this.dataList)
  812. })
  813. },
  814. getWebsit() {
  815. getWebsit({ type: 'C' }).then(res => {
  816. this.websitList = res.data
  817. })
  818. },
  819. changeWebsit(e) {
  820. this.dataList = []
  821. this.formData.websitId = e.websitId
  822. this.formData.websitName = e.name
  823. this.formData.storageName = ''
  824. this.formData.storageId = ''
  825. this.getWorker()
  826. this.getCategory(e.websitId, this.formData.storageId)
  827. this.getWarehouseList(e.websitId)
  828. },
  829. changeStorage(e) {
  830. if (!this.formData.isImport && this.formData.orderSource == 'SELF') {
  831. this.dataList = []
  832. }
  833. this.formData.storageId = e.storageId
  834. this.formData.storageName = e.storageName
  835. this.getCategory(this.formData.websitId, e.storageId)
  836. },
  837. getCategory(websitId, storageId) {
  838. if (websitId && storageId) {
  839. getCategory({ websitId, storageId }).then(res => {
  840. this.mainList = res.data
  841. })
  842. } else {
  843. this.mainList = []
  844. }
  845. },
  846. toAddProject() {
  847. this.$router.push({
  848. name: 'basicEngineeringData'
  849. })
  850. },
  851. getProject() {
  852. getProject({
  853. pageNum: 1,
  854. pageSize: -1,
  855. params: []
  856. }).then(res => {
  857. this.projectList = res.data.records
  858. })
  859. },
  860. getWarehouseList(websitId) {
  861. if (!websitId) {
  862. return (this.warehouseList = [])
  863. }
  864. storageListPageV2({
  865. pageNum: 1,
  866. pageSize: -1,
  867. params: [
  868. { param: 'a.type', compare: 'like', value: '辅材' },
  869. { param: 'a.status', compare: '=', value: 'true' },
  870. { param: 'a.websit_id', compare: '=', value: websitId }
  871. ]
  872. }).then(res => {
  873. this.warehouseList = res.data.records
  874. })
  875. },
  876. getProjectCollectionList(orderEnginBaseId) {
  877. getProjectCollectionList({ orderEnginBaseId, goodsType: 'M' }).then(res => {
  878. this.collectionList = res.data
  879. })
  880. },
  881. async getGoods(categoryId, goodsName, type) {
  882. // if(!this.formData.storageId){return this.$message.warning('请先选择出库仓库!')}
  883. const that = this
  884. if (type == 1) {
  885. return new Promise((resolve, reject) => {
  886. getGoods({
  887. websitId: this.formData.websitId,
  888. categoryId: categoryId,
  889. type: 'M',
  890. goodsName: goodsName,
  891. orderEnginBaseId: this.formData.orderEnginBaseId,
  892. saleType: this.formData.salesType,
  893. storageId: this.formData.storageId
  894. }).then(res => {
  895. resolve({
  896. data: res.data[0]
  897. })
  898. })
  899. })
  900. } else {
  901. getGoods({
  902. websitId: this.formData.websitId,
  903. categoryId: categoryId,
  904. type: 'M',
  905. orderEnginBaseId: this.formData.orderEnginBaseId,
  906. saleType: this.formData.salesType,
  907. storageId: this.formData.storageId
  908. }).then(res => {
  909. that.dataList[that.isEdit].goodsList = res.data
  910. })
  911. }
  912. },
  913. getWorker() {
  914. getWorker({
  915. pageNum: 1,
  916. pageSize: -1,
  917. params: this.formType == 2 ? [] : [{ param: 'b.websit_id', compare: '=', value: this.formData.websitId }]
  918. }).then(res => {
  919. this.workerList = res.data.records
  920. })
  921. },
  922. changeWorker(e) {
  923. this.formData.identity = e.idCard
  924. this.formData.workerMobile = e.mobile
  925. this.formData.workerId = e.workerNumber
  926. this.formData.workerName = e.nickName
  927. },
  928. workerBlur(e) {
  929. this.formData.worker = e.target.value
  930. this.$forceUpdate()
  931. },
  932. changeMain(e) {
  933. ;(this.dataList[this.isEdit].goodsList = []),
  934. (this.dataList[this.isEdit].parentCategory = e),
  935. (this.dataList[this.isEdit].parentCategoryId = e.categoryId),
  936. (this.dataList[this.isEdit].parentCategoryName = e.categoryName),
  937. (this.dataList[this.isEdit].goodsCategory = {}),
  938. (this.dataList[this.isEdit].goodsCategoryName = ''),
  939. (this.dataList[this.isEdit].goodsCategoryId = ''),
  940. (this.dataList[this.isEdit].goods = {}),
  941. (this.dataList[this.isEdit].goodsId = ''),
  942. (this.dataList[this.isEdit].goodsName = ''),
  943. (this.dataList[this.isEdit].goodsSalesUnit = ''),
  944. (this.dataList[this.isEdit].goodsSpecification = ''),
  945. (this.dataList[this.isEdit].goodsCode = ''),
  946. (this.dataList[this.isEdit].price = ''),
  947. (this.dataList[this.isEdit].saleAmount = ''),
  948. (this.dataList[this.isEdit].salesQty = '')
  949. ;(this.dataList[this.isEdit].qty = ''), (this.dataList[this.isEdit].goodsType = 'M')
  950. },
  951. async changeSmall(e) {
  952. ;(this.dataList[this.isEdit].goods = {}),
  953. (this.dataList[this.isEdit].goodsId = ''),
  954. (this.dataList[this.isEdit].goodsName = ''),
  955. (this.dataList[this.isEdit].goodsSalesUnit = ''),
  956. (this.dataList[this.isEdit].goodsSpecification = ''),
  957. (this.dataList[this.isEdit].goodsCode = ''),
  958. (this.dataList[this.isEdit].price = ''),
  959. (this.dataList[this.isEdit].saleAmount = ''),
  960. (this.dataList[this.isEdit].salesQty = '')
  961. ;(this.dataList[this.isEdit].qty = ''), (this.dataList[this.isEdit].goodsCategoryId = e.categoryId)
  962. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  963. // if(!this.formData.storageId){return this.$message.warning('请先选择出库仓库!')}
  964. getGoods({
  965. websitId: this.formData.websitId,
  966. categoryId: e.categoryId,
  967. type: 'M',
  968. orderEnginBaseId: this.formData.orderEnginBaseId,
  969. saleType: this.formData.salesType,
  970. storageId: this.formData.storageId
  971. }).then(res => {
  972. this.dataList[this.isEdit].goodsList = res.data
  973. })
  974. },
  975. changeGoods(e) {
  976. console.log(e)
  977. this.dataList[this.isEdit].goodsId = e.goodsId
  978. this.dataList[this.isEdit].goodsName = e.goodsName
  979. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  980. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  981. this.dataList[this.isEdit].price = e.price
  982. this.dataList[this.isEdit].goodsCode = e.goodsCode
  983. this.dataList[this.isEdit].qty = e.qty
  984. this.dataList[this.isEdit].itemSourceType = e.itemSourceType
  985. this.dataList[this.isEdit].itemSourceId = e.itemSourceId
  986. this.dataList[this.isEdit].normType = e.normType
  987. },
  988. add() {
  989. if (this.dataList.length != 0) {
  990. this.isEdit = 0
  991. }
  992. this.dataList.unshift({
  993. goodsList: [],
  994. parentCategory: {},
  995. parentCategoryId: '',
  996. parentCategoryName: '',
  997. goodsCategory: {},
  998. goodsCategoryName: '',
  999. goodsCategoryId: '',
  1000. goods: {},
  1001. goodsId: '',
  1002. goodsName: '',
  1003. goodsSalesUnit: '',
  1004. goodsSpecification: '',
  1005. goodsCode: '',
  1006. price: '',
  1007. saleAmount: '',
  1008. salesQty: 1,
  1009. qty: '',
  1010. goodsType: 'M',
  1011. itemSourceType: '',
  1012. itemSourceId: '',
  1013. normType: ''
  1014. })
  1015. },
  1016. del(index) {
  1017. if (index <= 1) {
  1018. this.isEdit == 0
  1019. } else {
  1020. this.isEdit -= 1
  1021. }
  1022. this.dataList.splice(index, 1)
  1023. },
  1024. confirmSubmit() {
  1025. if (this.formData1.price && !/^[1-9]\d*(\.\d+)?$|^0\.[0-9]\d*$/.test(this.formData1.price)) {
  1026. return this.$message.warning('请输入大于0的数字!')
  1027. }
  1028. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  1029. confirmButtonText: '确定',
  1030. cancelButtonText: '取消',
  1031. type: 'warning'
  1032. }).then(() => {
  1033. submit({
  1034. salesId: this.formData.salesId,
  1035. price: this.formData1.price,
  1036. urlPrc: this.formData1.fileUrl.length > 0 ? this.formData1.fileUrl[0].url : '',
  1037. remark: this.formData1.remark
  1038. }).then(res => {
  1039. if (res.code == 200) {
  1040. this.$message.success('提交成功!')
  1041. if (this.formData.payType == 'ALLINPAY') {
  1042. this.wxPay()
  1043. } else {
  1044. this.goBack()
  1045. }
  1046. }
  1047. })
  1048. })
  1049. },
  1050. submit() {
  1051. const that = this
  1052. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  1053. if (valid) {
  1054. edit({
  1055. salesId: this.formData.salesId,
  1056. goodsType: 'M',
  1057. orderSource: this.formData.orderSource,
  1058. payType: this.formData.payType,
  1059. remark: this.formData.remark,
  1060. websitId: this.formData.websitId,
  1061. websitName: this.formData.websitName,
  1062. workerName: this.formData.workerName,
  1063. workerId: this.formData.workerId,
  1064. identity: this.formData.identity,
  1065. workerMobile: this.formData.workerMobile,
  1066. buyPeople: this.formData.buyPeople,
  1067. items: this.dataList,
  1068. orderEnginBaseId: this.formData.orderEnginBaseId,
  1069. salesType: this.formData.salesType,
  1070. storageId: this.formData.storageId,
  1071. storageName: this.formData.storageName
  1072. }).then(res => {
  1073. if (res.code == 200) {
  1074. this.$nextTick(() => {
  1075. that.confirmSubmit()
  1076. })
  1077. }
  1078. })
  1079. }
  1080. })
  1081. },
  1082. confirm() {
  1083. if (!this.formData.storageId) {
  1084. return this.$message.warning('请先选择出库仓库!')
  1085. }
  1086. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  1087. confirmButtonText: '确定',
  1088. cancelButtonText: '取消',
  1089. type: 'warning'
  1090. }).then(() => {
  1091. confirm({
  1092. salesId: this.formData.salesId,
  1093. storageId: this.formData.storageId
  1094. }).then(res => {
  1095. if (res.code == 200) {
  1096. this.$message.success('审核成功!')
  1097. this.goBack()
  1098. }
  1099. })
  1100. })
  1101. },
  1102. checkPay() {
  1103. this.timer = setInterval(() => {
  1104. getDetail({ salesId: this.id }).then(res => {
  1105. if (res.data.payFlag == 'YES') {
  1106. this.$refs.payQRCode.innerHTML = ''
  1107. this.clear()
  1108. this.$message.success('支付成功!')
  1109. this.goBack()
  1110. }
  1111. })
  1112. }, 3000)
  1113. },
  1114. clear() {
  1115. clearInterval(this.timer)
  1116. },
  1117. wxPay() {
  1118. if (!this.is_submit) {
  1119. return false
  1120. }
  1121. adminWebsitPayConfigList({
  1122. status: true,
  1123. type: 'M',
  1124. websitId: this.formData.websitId
  1125. }).then(resd => {
  1126. selectEl
  1127. .bind(this)(
  1128. resd?.data?.map(item => ({
  1129. value: item.id,
  1130. label: item.name
  1131. }))
  1132. )
  1133. .then(val => {
  1134. this.is_submit = false
  1135. setTimeout(() => {
  1136. this.is_submit = true
  1137. }, 2000)
  1138. getCode({
  1139. payConfigId: val,
  1140. salesId: this.formData.salesId
  1141. }).then(res => {
  1142. if (res.code == 200) {
  1143. this.isPay = true
  1144. this.$nextTick(() => {
  1145. this.payCodeUrl = res.data.codeUrl
  1146. this.$refs.payQRCode.innerHTML = ''
  1147. this.$nextTick(() => {
  1148. this.payUrl = res.data.codeUrl
  1149. new QRCode(this.$refs.payQRCode, {
  1150. text: res.data.codeUrl,
  1151. width: 200,
  1152. height: 200,
  1153. colorDark: '#333333', // 二维码颜色
  1154. colorLight: '#ffffff', // 二维码背景色
  1155. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  1156. })
  1157. this.checkPay()
  1158. })
  1159. })
  1160. }
  1161. })
  1162. })
  1163. })
  1164. },
  1165. save() {
  1166. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  1167. if (valid) {
  1168. if (this.formType == 0) {
  1169. add({
  1170. goodsType: 'M',
  1171. orderSource: this.formData.orderSource,
  1172. payType: this.formData.payType,
  1173. remark: this.formData.remark,
  1174. websitId: this.formData.websitId,
  1175. websitName: this.formData.websitName,
  1176. workerName: this.formData.workerName,
  1177. workerId: this.formData.workerId,
  1178. identity: this.formData.identity,
  1179. workerMobile: this.formData.workerMobile,
  1180. buyPeople: this.formData.buyPeople,
  1181. items: this.dataList,
  1182. orderEnginBaseId: this.formData.orderEnginBaseId,
  1183. salesType: this.formData.salesType,
  1184. storageId: this.formData.storageId,
  1185. storageName: this.formData.storageName
  1186. }).then(res => {
  1187. if (res.code == 200) {
  1188. this.$message.success('提交成功!')
  1189. this.goBack()
  1190. }
  1191. })
  1192. } else if (this.formType == 1) {
  1193. edit({
  1194. salesId: this.formData.salesId,
  1195. goodsType: 'M',
  1196. orderSource: this.formData.orderSource,
  1197. payType: this.formData.payType,
  1198. remark: this.formData.remark,
  1199. websitId: this.formData.websitId,
  1200. websitName: this.formData.websitName,
  1201. workerName: this.formData.workerName,
  1202. workerId: this.formData.workerId,
  1203. identity: this.formData.identity,
  1204. workerMobile: this.formData.workerMobile,
  1205. buyPeople: this.formData.buyPeople,
  1206. items: this.dataList,
  1207. orderEnginBaseId: this.formData.orderEnginBaseId,
  1208. salesType: this.formData.salesType,
  1209. storageId: this.formData.storageId,
  1210. storageName: this.formData.storageName
  1211. }).then(res => {
  1212. if (res.code == 200) {
  1213. this.dataList = []
  1214. this.$message.success('提交成功!')
  1215. this.goBack()
  1216. }
  1217. })
  1218. }
  1219. }
  1220. })
  1221. },
  1222. changeSale() {
  1223. this.formData.buyPeople = 'CUSTOMER'
  1224. },
  1225. getinitlbslist() {
  1226. // 初始化请求省市区街道下拉选项数据
  1227. lbsAmapRegion({ pid: 0 }).then(res => {
  1228. this.provinceList = res.data
  1229. // 创建工单时获取ip地址定位赋值
  1230. if (!this.id && this.$IpAdd.province) {
  1231. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  1232. if (item) {
  1233. this.formData.provinceId = item.id
  1234. this.formData.province = item.name
  1235. }
  1236. }
  1237. if (this.formData.provinceId) {
  1238. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  1239. this.cityList = res.data
  1240. // 创建工单时获取ip地址定位赋值
  1241. if (!this.id && this.$IpAdd.city) {
  1242. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  1243. if (item2) {
  1244. this.formData.cityId = item2.id
  1245. this.formData.city = item2.name
  1246. }
  1247. }
  1248. if (this.formData.cityId) {
  1249. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  1250. this.areaList = res.data
  1251. })
  1252. }
  1253. if (this.formData.areaId) {
  1254. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  1255. this.streetList = res.data
  1256. })
  1257. }
  1258. })
  1259. }
  1260. })
  1261. },
  1262. selectAddress(data) {
  1263. this.formData.lng = data.center[0]
  1264. this.formData.lat = data.center[1]
  1265. // 获取定位的省市区街道
  1266. var { province, city, district, township } = data.data.addressComponent
  1267. // 获取选中省名称id
  1268. var { id, name } = this.provinceList.find(item => item.name === province)
  1269. this.formData.provinceId = id
  1270. this.formData.province = name
  1271. // 请求市选项
  1272. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  1273. // 赋值市选项
  1274. this.cityList = res.data
  1275. // 获取选中市名称id
  1276. var { id, name } = res.data.find(item => item.name === city)
  1277. this.formData.cityId = id
  1278. this.formData.city = name
  1279. // 请求区选项
  1280. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  1281. // 赋值区选项
  1282. this.areaList = res.data
  1283. // 获取选中区名称id
  1284. var { id, name } = res.data.find(item => item.name === district)
  1285. this.formData.areaId = id
  1286. this.formData.area = name
  1287. // 请求街道选项
  1288. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  1289. // 赋值街道选项
  1290. this.streetList = res.data
  1291. // 获取选中街道名称id
  1292. var { id, name } = res.data.find(item => item.name === township)
  1293. this.formData.streetId = id
  1294. this.formData.street = name
  1295. // 赋值GPS详细地址
  1296. this.formData.address = data.name
  1297. })
  1298. })
  1299. })
  1300. }
  1301. }
  1302. }
  1303. </script>
  1304. <style scoped="scoped" lang="scss">
  1305. .s-page {
  1306. padding: 20px;
  1307. background-color: #ffffff;
  1308. }
  1309. .page-footer {
  1310. height: 70px;
  1311. }
  1312. .footer {
  1313. position: fixed;
  1314. bottom: 0;
  1315. left: 0;
  1316. z-index: 1;
  1317. width: 100%;
  1318. background: #fff;
  1319. padding: 15px 40px;
  1320. box-sizing: border-box;
  1321. transition: all 0.28s;
  1322. text-align: right;
  1323. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  1324. &.hideSidebar {
  1325. margin-left: 54px;
  1326. width: calc(100vw - 54px);
  1327. }
  1328. &.openSidebar {
  1329. margin-left: 210px;
  1330. width: calc(100vw - 210px);
  1331. }
  1332. .tips {
  1333. font-size: 12px;
  1334. color: red;
  1335. margin-top: 10px;
  1336. }
  1337. }
  1338. </style>