attachmentSalesOrderDetail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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 type="text" :value="formData.flag == 'SAVE'?'已保存':formData.flag == 'SUBMIT'?'已提交':formData.flag == 'CANCEL'?'取消订单':formData.flag == 'PAY_NOT_TAKE'?'已支付,未提货':formData.flag == 'PAY_TAKE'?'已支付,已提货':''" disabled></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="8" v-if="id">
  18. <el-form-item label="单据编号">
  19. <el-input type="text" :value="formData.salesId" disabled></el-input>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="8">
  23. <el-form-item label="所属商户" :required="true" >
  24. <el-input type="text" :value="companyName" disabled></el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="8">
  28. <el-form-item label="网点名称" prop="websitId" :required="true">
  29. <el-select v-model="formData.websit" :disabled="formType == 2" value-key="websitId" @change="changeWebsit" placeholder="请选择" style="width: 100%;">
  30. <el-option
  31. v-for="item in websitList"
  32. :key="item.websitId"
  33. :label="item.name"
  34. :value="item">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="购买方" :required="true" style="padding-bottom: 1px;">
  41. <el-radio-group v-model="formData.buyPeople" @change="formData.workerName = '';formData.workerMobile=''">
  42. <el-radio :disabled="(formData.flag != 'SAVE' && formType!=0) || formData.salesType == '工程'" label="WORKER">内部师傅</el-radio>
  43. <el-radio :disabled="(formData.flag != 'SAVE' && formType!=0) || formData.salesType == '工程'" label="CUSTOMER">客户</el-radio>
  44. </el-radio-group>
  45. </el-form-item>
  46. </el-col>
  47. <template v-if="formData.buyPeople == 'CUSTOMER'">
  48. <el-col :span="8">
  49. <el-form-item label="客户姓名" prop="workerName" :required="true">
  50. <el-input type="text" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.workerName" placeholder="请输入"></el-input>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="客户联系电话" prop="workerMobile" :required="true">
  55. <el-input type="text" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.workerMobile" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. </template>
  59. <template v-else>
  60. <el-col :span="8">
  61. <el-form-item label="师傅姓名" prop="worker" :required="true">
  62. <el-select v-model="formData.worker" :disabled="formType == 2" value-key="nickName" @focus="()=>{
  63. if(!this.formData.websitId){return this.$message.warning('请先选择网点名称!');}
  64. }" filterable @change="changeWorker" @blur="workerBlur" placeholder="请选择" style="width: 100%;">
  65. <el-option
  66. v-for="item in workerList"
  67. :key="item.id"
  68. :label="item.nickName + '-' + item.mobile"
  69. :value="item">
  70. </el-option>
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. <!-- <el-col :span="8">
  75. <el-form-item label="师傅身份证" prop="identity" :required="true">
  76. <el-input type="text" v-model="formData.identity" :disabled="formType == 2" placeholder="请输入"></el-input>
  77. </el-form-item>
  78. </el-col> -->
  79. <el-col :span="8">
  80. <el-form-item label="师傅联系电话" prop="workerMobile" :required="true">
  81. <el-input type="text" v-model="formData.workerMobile" :disabled="formType == 2" placeholder="请输入"></el-input>
  82. </el-form-item>
  83. </el-col>
  84. </template>
  85. <el-col :span="8">
  86. <el-form-item label="销售类型" :required="true" style="padding-bottom: 1px;">
  87. <el-radio-group v-model="formData.salesType" @change="changeSale">
  88. <el-radio :disabled="formData.flag != 'SAVE' && formType!=0" label="零售">零售</el-radio>
  89. <el-radio :disabled="formData.flag != 'SAVE' && formType!=0" label="工程">工程</el-radio>
  90. </el-radio-group>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="6" v-if="id">
  94. <el-form-item label="单据金额">
  95. <el-input type="text" :value="formData.totalAmount" disabled></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="8">
  99. <el-form-item label="订单来源" prop="source" :required="true">
  100. <el-select v-model="formData.source" :disabled="true" placeholder="请选择" style="width: 100%;">
  101. <el-option
  102. v-for="item in [{name: '在线订单',id: 'ONLINE'},{name: '自建订单',id: 'SELF'}]"
  103. :key="item.id"
  104. :label="item.name"
  105. :value="item.id">
  106. </el-option>
  107. </el-select>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="6">
  111. <el-form-item label="支付方式" prop="payType" :required="true">
  112. <el-radio-group v-model="formData.payType">
  113. <el-radio :disabled="formType == 2" label="CASH">现金</el-radio>
  114. <el-radio :disabled="formType == 2" label="WECHAT">微信</el-radio>
  115. <el-radio v-if="formData.salesType == '工程'" :disabled="formData.flag != 'SAVE' && formType!=0" label="ENGIN">工程支付</el-radio>
  116. </el-radio-group>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="2" v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'">
  120. <div style="height: 32px;display: flex;align-items: center;cursor: pointer;" @click="wxPay()">微信支付<i class="el-icon-full-screen"></i></div>
  121. </el-col>
  122. <el-col :span="2" v-else>
  123. <div style="opacity: 0;">隐藏</div>
  124. </el-col>
  125. <template v-if="formData.salesType == '工程'">
  126. <el-col :span="8">
  127. <el-form-item label="工程名称" prop="project" :required="true">
  128. <el-select v-model="formData.project" value-key="id" @change="(e)=>{
  129. formData.orderEnginBaseId = e.id
  130. }" :disabled="formData.flag != 'SAVE' && formType!=0" placeholder="请选择" style="width: 100%;">
  131. <el-option
  132. v-for="(item,index) in projectList"
  133. :key="index"
  134. :label="item.projectName"
  135. :value="item">
  136. </el-option>
  137. </el-select>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="6">
  141. <el-form-item label="工程编号" :required="true">
  142. <el-input type="text" :disabled="true" v-model="formData.project.projectNo" placeholder="请输入"></el-input>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="6">
  146. <el-form-item label="负责人" :required="true">
  147. <el-input type="text" :disabled="true" v-model="formData.project.manger" placeholder="请输入"></el-input>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="6">
  151. <el-form-item label="联系电话" :required="true">
  152. <el-input type="text" :disabled="true" v-model="formData.project.mobile" placeholder="请输入"></el-input>
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="6">
  156. <el-form-item label="项目时间" :required="true">
  157. <el-date-picker
  158. style="width:50%"
  159. v-model="formData.project.startTime"
  160. type="date"
  161. :disabled="true"
  162. value-format="yyyy-MM-dd"
  163. placeholder="开始日期">
  164. </el-date-picker>
  165. <el-date-picker
  166. style="width:50%"
  167. v-model="formData.project.endTime"
  168. type="date"
  169. :disabled="true"
  170. value-format="yyyy-MM-dd"
  171. placeholder="结束日期">
  172. </el-date-picker>
  173. </el-form-item>
  174. </el-col>
  175. <el-col :span="24">
  176. <el-form-item label="项目地址" prop="province" :required="true">
  177. <el-row>
  178. <el-col :span="5" style="margin-right: 12px;">
  179. <el-input type="text" v-model="formData.project.province" disabled placeholder="请选择省"></el-input>
  180. </el-col>
  181. <el-col :span="5" style="margin-right: 12px;">
  182. <el-input type="text" v-model="formData.project.city" disabled placeholder="请选择市"></el-input>
  183. </el-col>
  184. <el-col :span="5" style="margin-right: 12px;">
  185. <el-input type="text" v-model="formData.project.area" disabled placeholder="请选择区"></el-input>
  186. </el-col>
  187. <el-col :span="8">
  188. <el-input type="text" v-model="formData.project.street" disabled placeholder="请选择街道"></el-input>
  189. </el-col>
  190. </el-row>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="24">
  194. <el-form-item label="" prop="address">
  195. <el-row :gutter="20">
  196. <el-col :span="24">
  197. <el-input type="text" v-model="formData.project.address" :disabled="true" placeholder="详细地址"></el-input>
  198. </el-col>
  199. <!-- <el-col :span="2">
  200. <geographicalPosi :disabled="formType==2" :formData="this.formData" @selectPosi="selectAddress"/>
  201. </el-col> -->
  202. </el-row>
  203. </el-form-item>
  204. </el-col>
  205. </template>
  206. <el-col :span="6" v-if="id">
  207. <el-form-item label="制单人">
  208. <el-input type="text" :value="formData.createBy" disabled></el-input>
  209. </el-form-item>
  210. </el-col>
  211. <el-col :span="6" v-if="id">
  212. <el-form-item label="制单时间">
  213. <el-input type="text" :value="formData.createTime" disabled></el-input>
  214. </el-form-item>
  215. </el-col>
  216. <el-col :span="6" v-if="id">
  217. <el-form-item label="审核人">
  218. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  219. </el-form-item>
  220. </el-col>
  221. <el-col :span="6" v-if="id">
  222. <el-form-item label="审核时间">
  223. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  224. </el-form-item>
  225. </el-col>
  226. <el-col :span="24">
  227. <el-form-item label="备注">
  228. <el-input type="textarea" :rows="4" v-model="formData.remark" :disabled="formType == 2" placeholder="请输入"></el-input>
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. </el-form>
  233. </div>
  234. </el-card>
  235. <el-card class="box-card">
  236. <div slot="header" class="clearfix">
  237. <span>配件信息</span>
  238. </div>
  239. <el-button size="small" v-if="formData.flag == 'SAVE' || formType==0" type="primary" @click="add()">添加</el-button>
  240. <div class="table">
  241. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  242. <el-table-column label="配件名称" align="center">
  243. <template slot-scope="scope">
  244. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  245. <el-option
  246. v-for="item in scope.row.goodsList"
  247. :key="item.goodsId"
  248. :label="item.goodsName"
  249. :value="item">
  250. </el-option>
  251. </el-select>
  252. </template>
  253. </el-table-column>
  254. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  255. <el-table-column prop="" align="center" label="数量" >
  256. <template slot-scope="scope">
  257. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  258. </template>
  259. </el-table-column>
  260. <el-table-column prop="goods.goodsCode" align="center" label="配件编码"></el-table-column>
  261. <el-table-column prop="goods.brandRelaName" align="center" label="适用品牌"></el-table-column>
  262. <el-table-column prop="goods.productRelaName" align="center" label="适用产品大类"></el-table-column>
  263. <el-table-column prop="" align="center" label="销售价格">
  264. <template slot-scope="scope">
  265. <el-input type="number" v-model="scope.row.price" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  266. </template>
  267. </el-table-column>
  268. <el-table-column prop="goods.saleAmount" align="center" label="销售金额" >
  269. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.price">
  270. {{(scope.row.price * 100) * scope.row.salesQty / 100}}
  271. </template>
  272. </el-table-column>
  273. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  274. <el-table-column label="操作" align="right" width="140">
  275. <template slot-scope="scope" v-if="formType != 2">
  276. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  277. <el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. </div>
  282. </el-card>
  283. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0 && formData.flag == 'SAVE'">
  284. <div slot="header" class="clearfix">
  285. <span>收款信息</span>
  286. </div>
  287. <div class="mymain-container">
  288. <el-form ref="formData1" :rules="rules1" :model="formData1" label-width="110px" size="small" label-position="left">
  289. <el-row :gutter="20" justify="start">
  290. <el-col :span="24">
  291. <el-form-item label="收款金额">
  292. <el-input type="text" style="width: 30%" v-model="formData1.price" placeholder="请输入"></el-input>
  293. <span style="color: #FF8F47;margin-left: 10px">注:操作【提交】时,系统方可记录收款信息</span>
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="24">
  297. <el-form-item label="收款凭证">
  298. <ImageUpload :fileList="formData1.fileUrl" :limit="1" :isEdit="formType !== 2" />
  299. </el-form-item>
  300. </el-col>
  301. <el-col :span="24">
  302. <el-form-item label="备注">
  303. <el-input type="textarea" :rows="4" v-model="formData1.remark" placeholder="请输入"></el-input>
  304. </el-form-item>
  305. </el-col>
  306. </el-row>
  307. </el-form>
  308. </div>
  309. </el-card>
  310. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0">
  311. <div slot="header" class="clearfix">
  312. <span>收款记录</span>
  313. </div>
  314. <div class="table">
  315. <el-table :data="collectionList" element-loading-text="Loading" border fit highlight-current-row stripe>
  316. <el-table-column prop="status" label="收款结果" align="center">
  317. <template slot-scope="scope">
  318. {{scope.row.status == 'NO'?'未付款':scope.row.status == 'WAIT'?'部分付款':scope.row.status == 'OK'?'已完成':''}}
  319. </template>
  320. </el-table-column>
  321. <el-table-column prop="price" label="收款金额" align="center"></el-table-column>
  322. <el-table-column prop="" align="center" label="收款凭证" >
  323. <template slot-scope="scope" v-if="scope.row.urlPrc">
  324. <el-image style="width: 80px;" :src="scope.row.urlPrc" fit="scale-down" :preview-src-list="[scope.row.urlPrc]"></el-image>
  325. </template>
  326. </el-table-column>
  327. <el-table-column prop="remark" label="备注" align="center"></el-table-column>
  328. <el-table-column prop="updateBy" align="center" label="收款人" ></el-table-column>
  329. <el-table-column prop="updateTime" align="center" label="收款时间" ></el-table-column>
  330. </el-table>
  331. </div>
  332. </el-card>
  333. <div class="page-footer">
  334. <div class="footer">
  335. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  336. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  337. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  338. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  339. <el-button size="small" type="info" @click="goBack">返回</el-button>
  340. </div>
  341. </div>
  342. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  343. <h3 style="text-align: center;">扫二维码支付</h3>
  344. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  345. <div
  346. ref="payQRCode"
  347. style="display: flex; justify-content: center;"
  348. />
  349. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  350. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  351. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  352. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  353. </div>
  354. </el-dialog>
  355. </div>
  356. </template>
  357. <script>
  358. import { getWebsit } from "@/api/customerManagement";
  359. import QRCode from "qrcodejs2";
  360. import { lbsAmapRegion } from '@/api/common.js'
  361. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  362. import ImageUpload from '@/components/file-upload'
  363. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode, getProject, getProjectCollectionList } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  364. export default {
  365. components: {geographicalPosi,ImageUpload},
  366. props: ['id','title','formType'],
  367. data() {
  368. return {
  369. dataList: [],
  370. websitList: [],
  371. workerList: [],
  372. projectList: [],
  373. collectionList: [],
  374. isPay: false,
  375. is_submit: true,
  376. payCodeUrl: '',
  377. formData: {
  378. websit: {},
  379. websitId: '',
  380. websitName: '',
  381. file_url: [],
  382. salesId: '',
  383. flag: '',
  384. createBy: '',
  385. createTime: '',
  386. confirmBy: '',
  387. confirmTime: '',
  388. worker: {},
  389. workerName: '',
  390. workerId: '',
  391. identity: '',
  392. workerMobile: '',
  393. source: 'SELF',
  394. payType: '',
  395. totalAmount: '',
  396. remark: '',
  397. buyPeople: 'WORKER',
  398. salesType: '零售',
  399. province: '',
  400. provinceId: '',
  401. city: '',
  402. cityId: '',
  403. area: '',
  404. areaId: '',
  405. street: '',
  406. streetId: '',
  407. address: '',
  408. lat: '',
  409. lng: '',
  410. project: {},
  411. orderEnginBaseId: '',
  412. },
  413. formData1: {
  414. price: '',
  415. remark: '',
  416. fileUrl: []
  417. },
  418. provinceList: [],
  419. cityList: [],
  420. areaList: [],
  421. streetList: [],
  422. isEdit: 0,
  423. timer: '',
  424. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  425. rules: {
  426. websitId: [
  427. { required: true, message: '请选择网点', trigger: 'change' }
  428. ],
  429. worker: [
  430. { required: true, message: '请选择师傅', trigger: 'change' }
  431. ],
  432. source: [
  433. { required: true, message: '请选择订单来源', trigger: 'change' }
  434. ],
  435. payType: [
  436. { required: true, message: '请选择订单来源', trigger: 'change' }
  437. ],
  438. identity: [
  439. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  440. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  441. ],
  442. workerMobile: [
  443. { required: true, message: '请输入联系电话', trigger: 'blur' },
  444. { required: true, message: '请输入联系电话', trigger: 'change' },
  445. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  446. ],
  447. workerName: [
  448. { required: true, message: '请输入客户姓名', trigger: 'blur' }
  449. ],
  450. }
  451. };
  452. },
  453. computed: {},
  454. created() {
  455. if(this.id){
  456. this.getDetail()
  457. }
  458. this.getinitlbslist()
  459. this.getWebsit()
  460. this.getProject()
  461. },
  462. methods: {
  463. // 返回
  464. goBack() {
  465. this.$emit('back');
  466. },
  467. async getDetail(){
  468. const that = this
  469. getDetail({salesId: this.id}).then(async res => {
  470. Object.assign(this.formData, res.data, {
  471. websit: {websitId: res.data.websitId,name: res.data.websitName},
  472. worker: {nickName: res.data.workerName,userId: res.data.workerId},
  473. project: {id: res.data.orderEnginBaseId,projectName: res.data.projectName,projectNo: res.data.projectNo,manger: res.data.manger,mobile: res.data.mobile,startTime: res.data.startTime,endTime: res.data.endTime,province: res.data.province,provinceId: res.data.provinceId,city: res.data.city,cityId: res.data.cityId,area: res.data.area,areaId: res.data.areaId,street: res.data.street,streetId: res.data.streetId,address: res.data.address,lat: res.data.lat,lng: res.data.lng}
  474. })
  475. this.getWorker()
  476. if(res.data.salesType == '工程'){
  477. this.getProjectCollectionList(res.data.orderEnginBaseId)
  478. }
  479. for(var item of res.data.items){
  480. var ress = await that.getGoods(item.goodsName, 1)
  481. item.goods = {...ress.data,oldPrice:ress.data.price}
  482. item.goodsList = ress.data ? [{...ress.data,oldPrice:ress.data.price}] : []
  483. }
  484. this.dataList = res.data.items
  485. })
  486. },
  487. getWebsit(){
  488. getWebsit({type: 'C'}).then(res => {
  489. this.websitList = res.data
  490. })
  491. },
  492. changeWebsit(e){
  493. this.formData.websitId = e.websitId
  494. this.formData.websitName = e.name
  495. this.getWorker()
  496. },
  497. getProject(){
  498. getProject({
  499. pageNum: 1,
  500. pageSize: -1,
  501. params:[]
  502. }).then(res => {
  503. this.projectList = res.data.records
  504. })
  505. },
  506. getProjectCollectionList(orderEnginBaseId){
  507. getProjectCollectionList({orderEnginBaseId,goodsType: 'P'}).then(res => {
  508. this.collectionList = res.data
  509. })
  510. },
  511. async getGoods(goodsName,type){
  512. const that = this
  513. if(type == 1){
  514. return new Promise((resolve, reject) => {
  515. getGoods({websitId: this.formData.websitId,type: 'P',goodsName: goodsName,orderEnginBaseId: this.formData.orderEnginBaseId,saleType: this.formData.salesType}).then(res => {
  516. resolve({
  517. data: res.data[0]
  518. })
  519. })
  520. })
  521. }else{
  522. getGoods({websitId: this.formData.websitId,type: 'P',orderEnginBaseId: this.formData.orderEnginBaseId,saleType: this.formData.salesType}).then(res => {
  523. that.dataList[that.isEdit].goodsList = res.data
  524. console.log(this.dataList)
  525. })
  526. }
  527. },
  528. getWorker(){
  529. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  530. this.workerList = res.data.records
  531. })
  532. },
  533. changeWorker(e){
  534. this.formData.identity = e.idCard
  535. this.formData.workerMobile = e.mobile
  536. this.formData.workerId = e.userId
  537. this.formData.workerName = e.nickName
  538. },
  539. workerBlur(e){
  540. this.formData.worker = e.target.value
  541. this.$forceUpdate()
  542. },
  543. changeGoods(e){
  544. console.log(e)
  545. this.dataList[this.isEdit].goodsId = e.goodsId
  546. this.dataList[this.isEdit].goodsName = e.goodsName
  547. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  548. this.dataList[this.isEdit].brandRelaName = e.brandRelaName
  549. this.dataList[this.isEdit].productRelaName = e.productRelaName
  550. this.dataList[this.isEdit].price = e.price
  551. this.dataList[this.isEdit].goodsCode = e. goodsCode
  552. this.dataList[this.isEdit].qty = e.qty
  553. this.dataList[this.isEdit].itemSourceType = e.itemSourceType
  554. this.dataList[this.isEdit].itemSourceId = e.itemSourceId
  555. this.dataList[this.isEdit].normType = e.normType
  556. },
  557. add(){
  558. if(this.dataList.length != 0){this.isEdit = 0}
  559. this.dataList.unshift({
  560. goodsList: [],
  561. goods: {},
  562. goodsId: '',
  563. goodsName: '',
  564. goodsSalesUnit: '',
  565. brandRelaName: '',
  566. productRelaName: '',
  567. goodsCode: '',
  568. price: '',
  569. saleAmount: '',
  570. salesQty: 1,
  571. qty: '',
  572. goodsType: 'P',
  573. itemSourceType: '',
  574. itemSourceId: '',
  575. normType: ''
  576. })
  577. this.getGoods()
  578. },
  579. del(index){
  580. if(index <= 1){this.isEdit == 0}else{this.isEdit -= 1}
  581. this.dataList.splice(index,1)
  582. },
  583. submit(){
  584. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  585. confirmButtonText: '确定',
  586. cancelButtonText: '取消',
  587. type: 'warning'
  588. }).then(() => {
  589. submit({
  590. salesId: this.formData.salesId,
  591. price: this.formData1.price,
  592. urlPrc: this.formData1.fileUrl.length> 0 ?this.formData1.fileUrl[0].url: '',
  593. remark: this.formData1.remark
  594. }).then(res => {
  595. if(res.code == 200){
  596. this.$message.success('提交成功!')
  597. if(this.formData.payType == 'WECHAT'){
  598. this.wxPay()
  599. }else{
  600. this.goBack()
  601. }
  602. }
  603. })
  604. });
  605. },
  606. confirm(){
  607. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  608. confirmButtonText: '确定',
  609. cancelButtonText: '取消',
  610. type: 'warning'
  611. }).then(() => {
  612. confirm({
  613. salesId: this.formData.salesId
  614. }).then(res => {
  615. if(res.code == 200){
  616. this.$message.success('审核成功!')
  617. this.goBack()
  618. }
  619. })
  620. });
  621. },
  622. checkPay(){
  623. this.timer = setInterval(()=>{
  624. getDetail({salesId: this.id}).then(res => {
  625. if(res.data.payFlag == 'YES'){
  626. this.$refs.payQRCode.innerHTML = '';
  627. this.clear()
  628. this.$message.success('支付成功!')
  629. this.goBack()
  630. }
  631. })
  632. },3000)
  633. },
  634. clear(){
  635. clearInterval(this.timer)
  636. },
  637. wxPay(){
  638. if(!this.is_submit){
  639. return false
  640. }
  641. this.is_submit = false
  642. setTimeout(()=>{
  643. this.is_submit = true
  644. },2000)
  645. getCode({
  646. salesId: this.formData.salesId
  647. }).then(res => {
  648. if(res.code == 200){
  649. this.payCodeUrl = res.data.codeUrl
  650. this.$refs.payQRCode.innerHTML = '';
  651. this.$nextTick(() => {
  652. this.payUrl = res.data.codeUrl;
  653. new QRCode(this.$refs.payQRCode, {
  654. text: res.data.codeUrl,
  655. width: 200,
  656. height: 200,
  657. colorDark: "#333333", // 二维码颜色
  658. colorLight: "#ffffff", // 二维码背景色
  659. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  660. });
  661. this.checkPay()
  662. });
  663. }
  664. })
  665. this.isPay = true
  666. },
  667. save(){
  668. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  669. if (valid) {
  670. if(this.formType == 0){
  671. add({
  672. goodsType: 'P',
  673. source: this.formData.source,
  674. payType: this.formData.payType,
  675. remark: this.formData.remark,
  676. websitId: this.formData.websitId,
  677. websitName: this.formData.websitName,
  678. workerName: this.formData.workerName,
  679. workerId: this.formData.workerId,
  680. identity: this.formData.identity,
  681. workerMobile: this.formData.workerMobile,
  682. buyPeople: this.formData.buyPeople,
  683. items: this.dataList,
  684. orderEnginBaseId: this.formData.orderEnginBaseId,
  685. salesType: this.formData.salesType
  686. }).then(res => {
  687. if(res.code == 200){
  688. this.$message.success('提交成功!')
  689. this.goBack()
  690. }
  691. })
  692. }else if(this.formType == 1){
  693. edit({
  694. salesId: this.formData.salesId,
  695. goodsType: 'P',
  696. source: this.formData.source,
  697. payType: this.formData.payType,
  698. remark: this.formData.remark,
  699. websitId: this.formData.websitId,
  700. websitName: this.formData.websitName,
  701. workerName: this.formData.workerName,
  702. workerId: this.formData.workerId,
  703. identity: this.formData.identity,
  704. workerMobile: this.formData.workerMobile,
  705. buyPeople: this.formData.buyPeople,
  706. items: this.dataList,
  707. orderEnginBaseId: this.formData.orderEnginBaseId,
  708. salesType: this.formData.salesType
  709. }).then(res => {
  710. if(res.code == 200){
  711. this.dataList = []
  712. this.$message.success('提交成功!')
  713. this.goBack()
  714. }
  715. })
  716. }
  717. }
  718. })
  719. },
  720. changeSale(){
  721. this.formData.buyPeople = 'CUSTOMER'
  722. },
  723. getinitlbslist() {
  724. // 初始化请求省市区街道下拉选项数据
  725. lbsAmapRegion({ pid: 0 }).then(res => {
  726. this.provinceList = res.data
  727. // 创建工单时获取ip地址定位赋值
  728. if (!this.id && this.$IpAdd.province) {
  729. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  730. if (item) {
  731. this.formData.provinceId = item.id
  732. this.formData.province = item.name
  733. }
  734. }
  735. if (this.formData.provinceId) {
  736. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  737. this.cityList = res.data
  738. // 创建工单时获取ip地址定位赋值
  739. if (!this.id && this.$IpAdd.city) {
  740. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  741. if (item2) {
  742. this.formData.cityId = item2.id
  743. this.formData.city = item2.name
  744. }
  745. }
  746. if (this.formData.cityId) {
  747. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  748. this.areaList = res.data
  749. })
  750. }
  751. if (this.formData.areaId) {
  752. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  753. this.streetList = res.data
  754. })
  755. }
  756. })
  757. }
  758. })
  759. },
  760. selectAddress(data){
  761. this.formData.lng = data.center[0]
  762. this.formData.lat = data.center[1]
  763. // 获取定位的省市区街道
  764. var { province, city, district, township } = data.data.addressComponent
  765. // 获取选中省名称id
  766. var { id, name } = this.provinceList.find(item => item.name === province)
  767. this.formData.provinceId = id
  768. this.formData.province = name
  769. // 请求市选项
  770. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  771. // 赋值市选项
  772. this.cityList = res.data
  773. // 获取选中市名称id
  774. var { id, name } = res.data.find(item => item.name === city)
  775. this.formData.cityId = id
  776. this.formData.city = name
  777. // 请求区选项
  778. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  779. // 赋值区选项
  780. this.areaList = res.data
  781. // 获取选中区名称id
  782. var { id, name } = res.data.find(item => item.name === district)
  783. this.formData.areaId = id
  784. this.formData.area = name
  785. // 请求街道选项
  786. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  787. // 赋值街道选项
  788. this.streetList = res.data
  789. // 获取选中街道名称id
  790. var { id, name } = res.data.find(item => item.name === township)
  791. this.formData.streetId = id
  792. this.formData.street = name
  793. // 赋值GPS详细地址
  794. this.formData.address = data.name
  795. })
  796. })
  797. })
  798. },
  799. }
  800. };
  801. </script>
  802. <style scoped="scoped" lang="scss">
  803. .s-page {
  804. padding: 20px;
  805. background-color: #ffffff;
  806. }
  807. .page-footer {
  808. height: 70px;
  809. }
  810. .footer {
  811. position: fixed;
  812. bottom: 0;
  813. left: 0;
  814. z-index: 1;
  815. width: 100%;
  816. background: #fff;
  817. padding: 15px 40px;
  818. box-sizing: border-box;
  819. transition: all 0.28s;
  820. text-align: right;
  821. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  822. &.hideSidebar {
  823. margin-left: 54px;
  824. width: calc(100vw - 54px);
  825. }
  826. &.openSidebar {
  827. margin-left: 210px;
  828. width: calc(100vw - 210px);
  829. }
  830. .tips {
  831. font-size: 12px;
  832. color: red;
  833. margin-top: 10px;
  834. }
  835. }
  836. </style>