auxiliarySalesOrderDetail.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  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">
  29. <el-select v-model="formData.websit" :disabled="formData.flag != 'SAVE' && formType!=0" 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" label="WORKER">内部师傅</el-radio>
  43. <el-radio :disabled="formData.flag != 'SAVE' && formType!=0" 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">
  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">
  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">
  62. <el-select v-model="formData.worker" :disabled="formData.flag != 'SAVE' && formType!=0" 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" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.identity" placeholder="请输入"></el-input>
  77. </el-form-item>
  78. </el-col> -->
  79. <el-col :span="8">
  80. <el-form-item label="师傅联系电话" prop="workerMobile">
  81. <el-input type="text" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.workerMobile" 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="8" 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="formData.flag != 'SAVE' && formType!=0" label="CASH">现金</el-radio>
  114. <el-radio :disabled="formData.flag != 'SAVE' && formType!=0" 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.projectNo" 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.projectNo" 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" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.remark" 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.parentCategory" value-key="categoryId" @change="changeMain" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  245. <el-option
  246. v-for="item in mainList"
  247. :key="item.categoryId"
  248. :label="item.categoryName"
  249. :value="item">
  250. </el-option>
  251. </el-select>
  252. </template>
  253. </el-table-column>
  254. <el-table-column label="小类名称" align="center">
  255. <template slot-scope="scope">
  256. <el-select v-model="scope.row.goodsCategory" @change="changeSmall" @focus="()=>{
  257. if(!scope.row.parentCategory){return this.$message.warning('请先选择大类!');}
  258. }" :disabled="isEdit != scope.$index || formType == 2" value-key="categoryId" placeholder="请选择" style="width: 100%;">
  259. <el-option
  260. v-for="item in scope.row.parentCategory.items"
  261. :key="item.categoryId"
  262. :label="item.categoryName"
  263. :value="item">
  264. </el-option>
  265. </el-select>
  266. </template>
  267. </el-table-column>
  268. <el-table-column label="辅材名称" align="center">
  269. <template slot-scope="scope">
  270. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  271. <el-option
  272. v-for="item in scope.row.goodsList"
  273. :key="item.goodsId"
  274. :label="item.goodsName"
  275. :value="item">
  276. </el-option>
  277. </el-select>
  278. </template>
  279. </el-table-column>
  280. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  281. <el-table-column prop="" align="center" label="数量" >
  282. <template slot-scope="scope">
  283. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  284. </template>
  285. </el-table-column>
  286. <el-table-column prop="goods.goodsCode" align="center" label="商品代码"></el-table-column>
  287. <el-table-column prop="goods.goodsSpecification" align="center" label="规格型号"></el-table-column>
  288. <el-table-column prop="goods.price" align="center" label="销售价格"></el-table-column>
  289. <el-table-column prop="" align="center" label="销售金额" >
  290. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.goods && scope.row.goods.price">
  291. {{((scope.row.goods.price * 100) * scope.row.salesQty / 100).toFixed(2)}}
  292. </template>
  293. </el-table-column>
  294. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  295. <el-table-column label="操作" align="right" width="140">
  296. <template slot-scope="scope" v-if="formType != 2">
  297. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  298. <el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. </div>
  303. </el-card>
  304. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0 && formData.flag == 'SAVE'">
  305. <div slot="header" class="clearfix">
  306. <span>收款信息</span>
  307. </div>
  308. <div class="mymain-container">
  309. <el-form ref="formData1" :rules="rules1" :model="formData1" label-width="110px" size="small" label-position="left">
  310. <el-row :gutter="20" justify="start">
  311. <el-col :span="24">
  312. <el-form-item label="收款金额">
  313. <el-input type="text" style="width: 30%" v-model="formData1.price" placeholder="请输入"></el-input>
  314. <span style="color: #FF8F47;margin-left: 10px">注:操作【提交】时,系统方可记录收款信息</span>
  315. </el-form-item>
  316. </el-col>
  317. <el-col :span="24">
  318. <el-form-item label="收款凭证">
  319. <ImageUpload :fileList="formData1.fileUrl" :limit="1" :isEdit="formType !== 2" />
  320. </el-form-item>
  321. </el-col>
  322. <el-col :span="24">
  323. <el-form-item label="备注">
  324. <el-input type="textarea" :rows="4" v-model="formData1.remark" placeholder="请输入"></el-input>
  325. </el-form-item>
  326. </el-col>
  327. </el-row>
  328. </el-form>
  329. </div>
  330. </el-card>
  331. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0">
  332. <div slot="header" class="clearfix">
  333. <span>收款记录</span>
  334. </div>
  335. <div class="table">
  336. <el-table :data="collectionList" element-loading-text="Loading" border fit highlight-current-row stripe>
  337. <el-table-column prop="status" label="收款结果" align="center">
  338. <template slot-scope="scope">
  339. {{scope.row.status == 'NO'?'未付款':scope.row.status == 'WAIT'?'部分付款':scope.row.status == 'OK'?'已完成':''}}
  340. </template>
  341. </el-table-column>
  342. <el-table-column prop="price" label="收款金额" align="center"></el-table-column>
  343. <el-table-column prop="" align="center" label="收款凭证" >
  344. <template slot-scope="scope">
  345. <el-image :src="scope.row.urlPrc" fit="scale-down"></el-image>
  346. </template>
  347. </el-table-column>
  348. <el-table-column prop="remark" label="备注" align="center"></el-table-column>
  349. <el-table-column prop="updateBy" align="center" label="收款人" ></el-table-column>
  350. <el-table-column prop="updateTime" align="center" label="收款时间" ></el-table-column>
  351. </el-table>
  352. </div>
  353. </el-card>
  354. <div class="page-footer">
  355. <div class="footer">
  356. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  357. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  358. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  359. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认提货</el-button>
  360. <el-button size="small" type="info" @click="goBack">返回</el-button>
  361. </div>
  362. </div>
  363. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  364. <h3 style="text-align: center;">扫二维码支付</h3>
  365. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  366. <div
  367. ref="payQRCode"
  368. style="display: flex; justify-content: center;"
  369. />
  370. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  371. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  372. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  373. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  374. </div>
  375. </el-dialog>
  376. </div>
  377. </template>
  378. <script>
  379. import { getWebsit } from "@/api/customerManagement";
  380. import QRCode from "qrcodejs2";
  381. import { lbsAmapRegion } from '@/api/common.js'
  382. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  383. import ImageUpload from '@/components/file-upload'
  384. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode, getProject, getProjectCollectionList } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  385. export default {
  386. components: {geographicalPosi,ImageUpload},
  387. props: ['id','title','formType'],
  388. data() {
  389. return {
  390. dataList: [],
  391. websitList: [],
  392. workerList: [],
  393. mainList: [],
  394. projectList: [],
  395. collectionList: [],
  396. isPay: false,
  397. payCodeUrl: '',
  398. formData: {
  399. websit: {},
  400. websitId: '',
  401. websitName: '',
  402. file_url: [],
  403. salesId: '',
  404. flag: '',
  405. createBy: '',
  406. createTime: '',
  407. confirmBy: '',
  408. confirmTime: '',
  409. worker: {},
  410. workerName: '',
  411. workerId: '',
  412. identity: '',
  413. workerMobile: '',
  414. source: 'SELF',
  415. payType: '',
  416. remark: '',
  417. totalAmount: '',
  418. buyPeople: 'WORKER',
  419. salesType: '零售',
  420. province: '',
  421. provinceId: '',
  422. city: '',
  423. cityId: '',
  424. area: '',
  425. areaId: '',
  426. street: '',
  427. streetId: '',
  428. address: '',
  429. lat: '',
  430. lng: '',
  431. project: {},
  432. orderEnginBaseId: '',
  433. },
  434. formData1: {
  435. price: '',
  436. remark: '',
  437. fileUrl: []
  438. },
  439. provinceList: [],
  440. cityList: [],
  441. areaList: [],
  442. streetList: [],
  443. isEdit: 0,
  444. is_submit: true,
  445. timer: '',
  446. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  447. rules: {
  448. websitId: [
  449. { required: true, message: '请选择网点', trigger: 'change' }
  450. ],
  451. worker: [
  452. { required: true, message: '请选择师傅', trigger: 'change' }
  453. ],
  454. source: [
  455. { required: true, message: '请选择订单来源', trigger: 'change' }
  456. ],
  457. payType: [
  458. { required: true, message: '请选择订单来源', trigger: 'change' }
  459. ],
  460. identity: [
  461. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  462. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  463. ],
  464. workerMobile: [
  465. { required: true, message: `请输入联系电话`, trigger: 'blur' },
  466. { required: true, message: `请输入联系电话`, trigger: 'change' },
  467. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  468. ],
  469. workerName: [
  470. { required: true, message: '请输入客户姓名', trigger: 'blur' }
  471. ],
  472. },
  473. rules1: {}
  474. };
  475. },
  476. computed: {},
  477. created() {
  478. if(this.id){
  479. this.getDetail()
  480. }
  481. this.getinitlbslist()
  482. this.getWebsit()
  483. this.getProject()
  484. },
  485. methods: {
  486. // 返回
  487. goBack() {
  488. this.$emit('back');
  489. },
  490. async getDetail(){
  491. const that = this
  492. getDetail({salesId: this.id}).then( async res => {
  493. Object.assign(this.formData, res.data, {
  494. websit: {websitId: res.data.websitId,name: res.data.websitName},
  495. worker: {nickName: res.data.workerName,userId: res.data.workerId},
  496. 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}
  497. })
  498. this.getWorker()
  499. this.getCategory(res.data.websitId)
  500. if(res.data.salesType == '工程'){
  501. this.getProjectCollectionList(res.data.orderEnginBaseId)
  502. }
  503. this.formData.remark = res.data.remark
  504. for(var item of res.data.items){
  505. item.parentCategory = {categoryId: item.parentCategoryId,categoryName: item.parentCategoryName, items: [{categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}]}
  506. item.goodsCategory = {categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}
  507. var ress = await that.getGoods(item.goodsCategoryId,item.goodsName, 1)
  508. item.goods = ress.data
  509. item.goodsList = ress.data ? [ress.data] : []
  510. }
  511. this.dataList = res.data.items
  512. })
  513. },
  514. getWebsit(){
  515. getWebsit({type: 'C'}).then(res => {
  516. this.websitList = res.data
  517. })
  518. },
  519. changeWebsit(e){
  520. this.formData.websitId = e.websitId
  521. this.formData.websitName = e.name
  522. this.getWorker()
  523. this.getCategory(e.websitId)
  524. },
  525. getCategory(websitId){
  526. getCategory({websitId}).then(res => {
  527. this.mainList = res.data
  528. })
  529. },
  530. getProject(){
  531. getProject({
  532. pageNum: 1,
  533. pageSize: -1,
  534. params:[]
  535. }).then(res => {
  536. this.projectList = res.data.records
  537. })
  538. },
  539. getProjectCollectionList(orderEnginBaseId){
  540. getProjectCollectionList({orderEnginBaseId}).then(res => {
  541. this.collectionList = res.data
  542. })
  543. },
  544. async getGoods(categoryId,goodsName,type){
  545. const that = this
  546. if(type == 1){
  547. return new Promise((resolve, reject) => {
  548. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',goodsName: goodsName}).then(res => {
  549. resolve({
  550. data: res.data[0]
  551. })
  552. })
  553. })
  554. }else{
  555. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M'}).then(res => {
  556. that.dataList[that.isEdit].goodsList = res.data
  557. })
  558. }
  559. },
  560. getWorker(){
  561. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  562. this.workerList = res.data.records
  563. })
  564. },
  565. changeWorker(e){
  566. this.formData.identity = e.idCard
  567. this.formData.workerMobile = e.mobile
  568. this.formData.workerId = e.userId
  569. this.formData.workerName = e.nickName
  570. },
  571. workerBlur(e){
  572. this.formData.worker = e.target.value
  573. this.$forceUpdate()
  574. },
  575. changeMain(e){
  576. this.dataList[this.isEdit].goodsList = [],
  577. this.dataList[this.isEdit].parentCategory = e,
  578. this.dataList[this.isEdit].parentCategoryId = e.categoryId,
  579. this.dataList[this.isEdit].parentCategoryName = e.categoryName,
  580. this.dataList[this.isEdit].goodsCategory = {},
  581. this.dataList[this.isEdit].goodsCategoryName = '',
  582. this.dataList[this.isEdit].goodsCategoryId = '',
  583. this.dataList[this.isEdit].goods = {},
  584. this.dataList[this.isEdit].goodsId = '',
  585. this.dataList[this.isEdit].goodsName = '',
  586. this.dataList[this.isEdit].goodsSalesUnit = '',
  587. this.dataList[this.isEdit].goodsSpecification = '',
  588. this.dataList[this.isEdit].goodsCode = '',
  589. this.dataList[this.isEdit].price = '',
  590. this.dataList[this.isEdit].saleAmount = '',
  591. this.dataList[this.isEdit].salesQty = ''
  592. this.dataList[this.isEdit].qty = '',
  593. this.dataList[this.isEdit].goodsType = 'M'
  594. },
  595. async changeSmall(e){
  596. this.dataList[this.isEdit].goods = {},
  597. this.dataList[this.isEdit].goodsId = '',
  598. this.dataList[this.isEdit].goodsName = '',
  599. this.dataList[this.isEdit].goodsSalesUnit = '',
  600. this.dataList[this.isEdit].goodsSpecification = '',
  601. this.dataList[this.isEdit].goodsCode = '',
  602. this.dataList[this.isEdit].price = '',
  603. this.dataList[this.isEdit].saleAmount = '',
  604. this.dataList[this.isEdit].salesQty = ''
  605. this.dataList[this.isEdit].qty = '',
  606. this.dataList[this.isEdit].goodsCategoryId = e.categoryId
  607. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  608. getGoods({websitId: this.formData.websitId,categoryId: e.categoryId,type: 'M'}).then(res => {
  609. this.dataList[this.isEdit].goodsList = res.data
  610. })
  611. },
  612. changeGoods(e){
  613. console.log(e)
  614. this.dataList[this.isEdit].goodsId = e.goodsId
  615. this.dataList[this.isEdit].goodsName = e.goodsName
  616. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  617. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  618. this.dataList[this.isEdit].price = e.price
  619. this.dataList[this.isEdit].goodsCode = e. goodsCode
  620. this.dataList[this.isEdit].qty = e.qty
  621. },
  622. add(){
  623. if(this.dataList.length != 0){this.isEdit += 1}
  624. this.dataList.push({
  625. goodsList: [],
  626. parentCategory: {},
  627. parentCategoryId: '',
  628. parentCategoryName: '',
  629. goodsCategory: {},
  630. goodsCategoryName: '',
  631. goodsCategoryId: '',
  632. goods: {},
  633. goodsId: '',
  634. goodsName: '',
  635. goodsSalesUnit: '',
  636. goodsSpecification: '',
  637. goodsCode: '',
  638. price: '',
  639. saleAmount: '',
  640. salesQty: 1,
  641. qty: '',
  642. goodsType: 'M'
  643. })
  644. },
  645. del(index){
  646. if(this.dataList.length == 1){this.isEdit == 0}else{this.isEdit -= 1}
  647. this.dataList.splice(index,1)
  648. },
  649. submit(){
  650. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  651. confirmButtonText: '确定',
  652. cancelButtonText: '取消',
  653. type: 'warning'
  654. }).then(() => {
  655. submit({
  656. salesId: this.formData.salesId,
  657. price: this.formData1.price,
  658. urlPrc: this.formData1.fileUrl[0].url,
  659. remark: this.formData1.remark
  660. }).then(res => {
  661. if(res.code == 200){
  662. this.$message.success('提交成功!')
  663. if(this.formData.payType == 'WECHAT'){
  664. this.wxPay()
  665. }else{
  666. this.goBack()
  667. }
  668. }
  669. })
  670. });
  671. },
  672. confirm(){
  673. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  674. confirmButtonText: '确定',
  675. cancelButtonText: '取消',
  676. type: 'warning'
  677. }).then(() => {
  678. confirm({
  679. salesId: this.formData.salesId
  680. }).then(res => {
  681. if(res.code == 200){
  682. this.$message.success('审核成功!')
  683. this.goBack()
  684. }
  685. })
  686. });
  687. },
  688. checkPay(){
  689. this.timer = setInterval(()=>{
  690. getDetail({salesId: this.id}).then(res => {
  691. if(res.data.payFlag == 'YES'){
  692. this.$refs.payQRCode.innerHTML = '';
  693. this.clear()
  694. this.$message.success('支付成功!')
  695. this.goBack()
  696. }
  697. })
  698. },3000)
  699. },
  700. clear(){
  701. clearInterval(this.timer)
  702. },
  703. wxPay(){
  704. if(!this.is_submit){
  705. return false
  706. }
  707. this.is_submit = false
  708. setTimeout(()=>{
  709. this.is_submit = true
  710. },2000)
  711. getCode({
  712. salesId: this.formData.salesId
  713. }).then(res => {
  714. if(res.code == 200){
  715. this.payCodeUrl = res.data.codeUrl
  716. this.$refs.payQRCode.innerHTML = '';
  717. this.$nextTick(() => {
  718. this.payUrl = res.data.codeUrl;
  719. new QRCode(this.$refs.payQRCode, {
  720. text: res.data.codeUrl,
  721. width: 200,
  722. height: 200,
  723. colorDark: "#333333", // 二维码颜色
  724. colorLight: "#ffffff", // 二维码背景色
  725. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  726. });
  727. this.checkPay()
  728. });
  729. }
  730. })
  731. this.isPay = true
  732. },
  733. save(){
  734. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  735. if (valid) {
  736. if(this.formType == 0){
  737. add({
  738. goodsType: 'M',
  739. source: this.formData.source,
  740. payType: this.formData.payType,
  741. remark: this.formData.remark,
  742. websitId: this.formData.websitId,
  743. websitName: this.formData.websitName,
  744. workerName: this.formData.workerName,
  745. workerId: this.formData.workerId,
  746. identity: this.formData.identity,
  747. workerMobile: this.formData.workerMobile,
  748. buyPeople: this.formData.buyPeople,
  749. items: this.dataList,
  750. orderEnginBaseId: this.formData.orderEnginBaseId,
  751. salesType: this.formData.salesType
  752. }).then(res => {
  753. if(res.code == 200){
  754. this.$message.success('提交成功!')
  755. this.goBack()
  756. }
  757. })
  758. }else if(this.formType == 1){
  759. edit({
  760. salesId: this.formData.salesId,
  761. goodsType: 'M',
  762. source: this.formData.source,
  763. payType: this.formData.payType,
  764. remark: this.formData.remark,
  765. websitId: this.formData.websitId,
  766. websitName: this.formData.websitName,
  767. workerName: this.formData.workerName,
  768. workerId: this.formData.workerId,
  769. identity: this.formData.identity,
  770. workerMobile: this.formData.workerMobile,
  771. buyPeople: this.formData.buyPeople,
  772. items: this.dataList,
  773. orderEnginBaseId: this.formData.orderEnginBaseId,
  774. salesType: this.formData.salesType
  775. }).then(res => {
  776. if(res.code == 200){
  777. this.dataList = []
  778. this.$message.success('提交成功!')
  779. this.goBack()
  780. }
  781. })
  782. }
  783. }
  784. })
  785. },
  786. changeSale(){
  787. },
  788. getinitlbslist() {
  789. // 初始化请求省市区街道下拉选项数据
  790. lbsAmapRegion({ pid: 0 }).then(res => {
  791. this.provinceList = res.data
  792. // 创建工单时获取ip地址定位赋值
  793. if (!this.id && this.$IpAdd.province) {
  794. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  795. if (item) {
  796. this.formData.provinceId = item.id
  797. this.formData.province = item.name
  798. }
  799. }
  800. if (this.formData.provinceId) {
  801. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  802. this.cityList = res.data
  803. // 创建工单时获取ip地址定位赋值
  804. if (!this.id && this.$IpAdd.city) {
  805. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  806. if (item2) {
  807. this.formData.cityId = item2.id
  808. this.formData.city = item2.name
  809. }
  810. }
  811. if (this.formData.cityId) {
  812. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  813. this.areaList = res.data
  814. })
  815. }
  816. if (this.formData.areaId) {
  817. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  818. this.streetList = res.data
  819. })
  820. }
  821. })
  822. }
  823. })
  824. },
  825. selectAddress(data){
  826. this.formData.lng = data.center[0]
  827. this.formData.lat = data.center[1]
  828. // 获取定位的省市区街道
  829. var { province, city, district, township } = data.data.addressComponent
  830. // 获取选中省名称id
  831. var { id, name } = this.provinceList.find(item => item.name === province)
  832. this.formData.provinceId = id
  833. this.formData.province = name
  834. // 请求市选项
  835. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  836. // 赋值市选项
  837. this.cityList = res.data
  838. // 获取选中市名称id
  839. var { id, name } = res.data.find(item => item.name === city)
  840. this.formData.cityId = id
  841. this.formData.city = name
  842. // 请求区选项
  843. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  844. // 赋值区选项
  845. this.areaList = res.data
  846. // 获取选中区名称id
  847. var { id, name } = res.data.find(item => item.name === district)
  848. this.formData.areaId = id
  849. this.formData.area = name
  850. // 请求街道选项
  851. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  852. // 赋值街道选项
  853. this.streetList = res.data
  854. // 获取选中街道名称id
  855. var { id, name } = res.data.find(item => item.name === township)
  856. this.formData.streetId = id
  857. this.formData.street = name
  858. // 赋值GPS详细地址
  859. this.formData.address = data.name
  860. })
  861. })
  862. })
  863. },
  864. }
  865. };
  866. </script>
  867. <style scoped="scoped" lang="scss">
  868. .s-page {
  869. padding: 20px;
  870. background-color: #ffffff;
  871. }
  872. .page-footer {
  873. height: 70px;
  874. }
  875. .footer {
  876. position: fixed;
  877. bottom: 0;
  878. left: 0;
  879. z-index: 1;
  880. width: 100%;
  881. background: #fff;
  882. padding: 15px 40px;
  883. box-sizing: border-box;
  884. transition: all 0.28s;
  885. text-align: right;
  886. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  887. &.hideSidebar {
  888. margin-left: 54px;
  889. width: calc(100vw - 54px);
  890. }
  891. &.openSidebar {
  892. margin-left: 210px;
  893. width: calc(100vw - 210px);
  894. }
  895. .tips {
  896. font-size: 12px;
  897. color: red;
  898. margin-top: 10px;
  899. }
  900. }
  901. </style>