attachmentSalesOrderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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 == 'OK'?'审核通过':formData.flag == 'OK'?'FAIL':''" 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="12">
  28. <el-form-item label="网点名称" prop="websitId" :required="true">
  29. <el-select v-model="formData.websit" 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="师傅姓名" prop="worker" :required="true">
  41. <el-select v-model="formData.worker" value-key="nickName" @focus="()=>{
  42. if(!this.formData.websitId){return this.$message.warning('请先选择网点名称!');}
  43. }" filterable @change="changeWorker" @blur="workerBlur" placeholder="请选择" style="width: 100%;">
  44. <el-option
  45. v-for="item in workerList"
  46. :key="item.id"
  47. :label="item.nickName"
  48. :value="item">
  49. </el-option>
  50. </el-select>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="8">
  54. <el-form-item label="师傅身份证" prop="idcard" :required="true">
  55. <el-input type="text" v-model="formData.idcard" placeholder="请输入"></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="8">
  59. <el-form-item label="师傅联系电话" prop="phone" :required="true">
  60. <el-input type="text" v-model="formData.phone" placeholder="请输入"></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="6" v-if="id">
  64. <el-form-item label="单据金额">
  65. <el-input type="text" :value="formData.createBy" disabled></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6" v-if="id">
  69. <el-form-item label="制单人">
  70. <el-input type="text" :value="formData.createBy" disabled></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6" v-if="id">
  74. <el-form-item label="制单时间">
  75. <el-input type="text" :value="formData.createTime" disabled></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6" v-if="id">
  79. <el-form-item label="审核人">
  80. <el-input type="text" :value="formData.confirmBy" disabled></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="6" v-if="id">
  84. <el-form-item label="审核时间">
  85. <el-input type="text" :value="formData.confirmTime" disabled></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12">
  89. <el-form-item label="订单来源" prop="source" :required="true">
  90. <el-select v-model="formData.source" placeholder="请选择" style="width: 100%;">
  91. <el-option
  92. v-for="item in [{name: '在线订单',id: 'ONLINE'},{name: '自建订单',id: 'SELF'}]"
  93. :key="item.id"
  94. :label="item.name"
  95. :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="9">
  101. <el-form-item label="支付方式" prop="payType" :required="true">
  102. <el-select v-model="formData.payType" placeholder="请选择" style="width: 100%;">
  103. <el-option
  104. v-for="item in [{name: '现金',id: 'CASH'},{name: '微信',id: 'WECHAT'}]"
  105. :key="item.id"
  106. :label="item.name"
  107. :value="item.id">
  108. </el-option>
  109. </el-select>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="3" v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'">
  113. <div style="height: 32px;display: flex;align-items: center;cursor: pointer;" @click="wxPay()">微信支付<i class="el-icon-full-screen"></i></div>
  114. </el-col>
  115. <el-col :span="24">
  116. <el-form-item label="备注">
  117. <el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </el-form>
  122. </div>
  123. </el-card>
  124. <el-card class="box-card">
  125. <div slot="header" class="clearfix">
  126. <span>配件信息</span>
  127. </div>
  128. <el-button size="small" type="primary" @click="add()">添加</el-button>
  129. <div class="table">
  130. <el-table :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  131. <el-table-column label="配件名称" align="center">
  132. <template slot-scope="scope">
  133. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index" placeholder="请选择" style="width: 100%;">
  134. <el-option
  135. v-for="item in scope.row.goodsList"
  136. :key="item.goodsId"
  137. :label="item.goodsName"
  138. :value="item">
  139. </el-option>
  140. </el-select>
  141. </template>
  142. </el-table-column>
  143. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  144. <el-table-column prop="" align="center" label="数量" >
  145. <template slot-scope="scope">
  146. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index" placeholder="请输入"></el-input>
  147. </template>
  148. </el-table-column>
  149. <el-table-column prop="goods.goodsCode" align="center" label="配件编码"></el-table-column>
  150. <el-table-column prop="goods.brandRelaName" align="center" label="适用品牌"></el-table-column>
  151. <el-table-column prop="goods.productRelaName" align="center" label="适用产品大类"></el-table-column>
  152. <el-table-column prop="goods.price" align="center" label="销售价格"></el-table-column>
  153. <el-table-column prop="goods.saleAmount" align="center" label="销售金额" ></el-table-column>
  154. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  155. <el-table-column label="操作" align="right" width="140">
  156. <template slot-scope="scope">
  157. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  158. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. </div>
  163. </el-card>
  164. <div class="page-footer">
  165. <div class="footer">
  166. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  167. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  168. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  169. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  170. <el-button size="small" type="info" @click="goBack">返回</el-button>
  171. </div>
  172. </div>
  173. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  174. <h3 style="text-align: center;">扫二维码支付</h3>
  175. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  176. <div
  177. ref="payQRCode"
  178. style="display: flex; justify-content: center;"
  179. />
  180. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  181. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  182. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  183. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  184. </div>
  185. </el-dialog>
  186. </div>
  187. </template>
  188. <script>
  189. import { getWebsit } from "@/api/customerManagement";
  190. import QRCode from "qrcodejs2";
  191. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  192. export default {
  193. props: ['id','title','formType'],
  194. data() {
  195. return {
  196. dataList: [],
  197. websitList: [],
  198. workerList: [],
  199. isPay: false,
  200. is_submit: true,
  201. payCodeUrl: '',
  202. formData: {
  203. websit: {},
  204. websitId: '',
  205. websitName: '',
  206. file_url: [],
  207. salesId: '',
  208. flag: '',
  209. createBy: '',
  210. createTime: '',
  211. confirmBy: '',
  212. confirmTime: '',
  213. worker: {},
  214. workerName: '',
  215. workerId: '',
  216. idcard: '',
  217. phone: '',
  218. source: '',
  219. payType: '',
  220. remark: ''
  221. },
  222. isEdit: 0,
  223. timer: '',
  224. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  225. rules: {
  226. websitId: [
  227. { required: true, message: '请选择网点', trigger: 'change' }
  228. ],
  229. worker: [
  230. { required: true, message: '请选择师傅', trigger: 'change' }
  231. ],
  232. source: [
  233. { required: true, message: '请选择订单来源', trigger: 'change' }
  234. ],
  235. payType: [
  236. { required: true, message: '请选择订单来源', trigger: 'change' }
  237. ],
  238. idcard: [
  239. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  240. ],
  241. phone: [
  242. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  243. ],
  244. }
  245. };
  246. },
  247. computed: {},
  248. created() {
  249. if(this.id){
  250. this.getDetail()
  251. }
  252. this.getWebsit()
  253. },
  254. methods: {
  255. // 返回
  256. goBack() {
  257. this.$emit('back');
  258. },
  259. async getDetail(){
  260. const that = this
  261. getDetail({salesId: this.id}).then(res => {
  262. this.formData.flag = res.data.flag
  263. this.formData.websit = {websitId: res.data.websitId,name: res.data.websitName}
  264. this.formData.websitId = res.data.websitId
  265. this.formData.websitName = res.data.websitName
  266. this.getWorker()
  267. this.formData.salesId = res.data.salesId
  268. this.formData.createBy = res.data.createBy
  269. this.formData.createTime = res.data.createTime
  270. this.formData.confirmBy = res.data.confirmBy
  271. this.formData.confirmTime = res.data.confirmTime
  272. this.formData.worker = {nickName: res.data.workerName,userId: res.data.workerId}
  273. this.formData.workerName = res.data.workerName
  274. this.formData.workerId = res.data.workerId
  275. this.formData.idcard = res.data.identity
  276. this.formData.phone = res.data.workerMobile
  277. this.formData.source = res.data.source
  278. this.formData.payType = res.data.payType
  279. this.formData.remark = res.data.remark
  280. res.data.items.forEach(item=>{
  281. that.getGoods(item.goodsName,1).then(ress => {
  282. item.goods = {...ress.data,oldPrice:ress.data.price}
  283. item.goodsList = [{...ress.data,oldPrice:ress.data.price}]
  284. })
  285. })
  286. setTimeout(()=>{
  287. this.dataList = res.data.items
  288. },200)
  289. console.log(this.dataList)
  290. })
  291. },
  292. getWebsit(){
  293. getWebsit({type: 'C'}).then(res => {
  294. this.websitList = res.data
  295. })
  296. },
  297. changeWebsit(e){
  298. this.formData.websitId = e.websitId
  299. this.formData.websitName = e.name
  300. this.getWorker()
  301. },
  302. async getGoods(goodsName,type){
  303. const that = this
  304. if(type == 1){
  305. return new Promise((resolve, reject) => {
  306. getGoods({websitId: this.formData.websitId,type: 'P',goodsName: goodsName}).then(res => {
  307. resolve({
  308. data: res.data[0]
  309. })
  310. })
  311. })
  312. }else{
  313. getGoods({websitId: this.formData.websitId,type: 'P'}).then(res => {
  314. that.dataList[that.isEdit].goodsList = res.data
  315. console.log(this.dataList)
  316. })
  317. }
  318. },
  319. getWorker(){
  320. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  321. this.workerList = res.data.records
  322. })
  323. },
  324. changeWorker(e){
  325. this.formData.idcard = e.idCard
  326. this.formData.phone = e.mobile
  327. this.formData.workerId = e.userId
  328. this.formData.workerName = e.nickName
  329. },
  330. workerBlur(e){
  331. this.formData.worker = e.target.value
  332. this.$forceUpdate()
  333. },
  334. changeGoods(e){
  335. console.log(e)
  336. this.dataList[this.isEdit].goodsId = e.goodsId
  337. this.dataList[this.isEdit].goodsName = e.goodsName
  338. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  339. this.dataList[this.isEdit].brandRelaName = e.brandRelaName
  340. this.dataList[this.isEdit].productRelaName = e.productRelaName
  341. this.dataList[this.isEdit].price = e.price
  342. this.dataList[this.isEdit].goodsCode = e. goodsCode
  343. this.dataList[this.isEdit].qty = e.qty
  344. },
  345. add(){
  346. this.dataList.push({
  347. goodsList: [],
  348. goods: {},
  349. goodsId: '',
  350. goodsName: '',
  351. goodsSalesUnit: '',
  352. brandRelaName: '',
  353. productRelaName: '',
  354. goodsCode: '',
  355. price: '',
  356. saleAmount: '',
  357. salesQty: 1,
  358. qty: '',
  359. goodsType: 'P'
  360. })
  361. this.getGoods()
  362. },
  363. submit(){
  364. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  365. confirmButtonText: '确定',
  366. cancelButtonText: '取消',
  367. type: 'warning'
  368. }).then(() => {
  369. submit({
  370. salesId: this.formData.salesId
  371. }).then(res => {
  372. if(res.code == 200){
  373. this.$message.success('提交成功!')
  374. if(this.formData.payType == 'WECHAT'){
  375. this.wxPay()
  376. }else{
  377. this.goBack()
  378. }
  379. }
  380. })
  381. });
  382. },
  383. confirm(){
  384. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  385. confirmButtonText: '确定',
  386. cancelButtonText: '取消',
  387. type: 'warning'
  388. }).then(() => {
  389. confirm({
  390. salesId: this.formData.salesId
  391. }).then(res => {
  392. if(res.code == 200){
  393. this.$message.success('审核成功!')
  394. this.goBack()
  395. }
  396. })
  397. });
  398. },
  399. checkPay(){
  400. this.timer = setInterval(()=>{
  401. getDetail({salesId: this.id}).then(res => {
  402. if(res.data.payFlag == 'YES'){
  403. this.clear()
  404. this.$message.success('支付成功!')
  405. this.goBack()
  406. }
  407. })
  408. },3000)
  409. },
  410. clear(){
  411. clearInterval(this.timer)
  412. },
  413. wxPay(){
  414. if(!this.is_submit){
  415. return false
  416. }
  417. this.is_submit = false
  418. setTimeout(()=>{
  419. this.is_submit = true
  420. },3000)
  421. getCode({
  422. salesId: this.formData.salesId
  423. }).then(res => {
  424. if(res.code == 200){
  425. this.payCodeUrl = res.data.codeUrl
  426. this.isPay = true
  427. this.$nextTick(() => {
  428. this.payUrl = res.data.codeUrl;
  429. new QRCode(this.$refs.payQRCode, {
  430. text: res.data.codeUrl,
  431. width: 200,
  432. height: 200,
  433. colorDark: "#333333", // 二维码颜色
  434. colorLight: "#ffffff", // 二维码背景色
  435. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  436. });
  437. this.checkPay()
  438. });
  439. }
  440. })
  441. },
  442. save(){
  443. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  444. if (valid) {
  445. if(this.formType == 0){
  446. add({
  447. goodsType: 'P',
  448. source: this.formData.source,
  449. payType: this.formData.payType,
  450. remark: this.formData.remark,
  451. websitId: this.formData.websitId,
  452. websitName: this.formData.websitName,
  453. workerName: this.formData.workerName,
  454. workerId: this.formData.workerId,
  455. identity: this.formData.idcard,
  456. workerMobile: this.formData.phone,
  457. items: this.dataList
  458. }).then(res => {
  459. if(res.code == 200){
  460. this.$message.success('提交成功!')
  461. this.goBack()
  462. }
  463. })
  464. }else if(this.formType == 1){
  465. edit({
  466. salesId: this.formData.salesId,
  467. goodsType: 'P',
  468. source: this.formData.source,
  469. payType: this.formData.payType,
  470. remark: this.formData.remark,
  471. websitId: this.formData.websitId,
  472. websitName: this.formData.websitName,
  473. workerName: this.formData.workerName,
  474. workerId: this.formData.workerId,
  475. identity: this.formData.idcard,
  476. workerMobile: this.formData.phone,
  477. items: this.dataList
  478. }).then(res => {
  479. if(res.code == 200){
  480. this.dataList = []
  481. this.$message.success('提交成功!')
  482. this.goBack()
  483. }
  484. })
  485. }
  486. }
  487. })
  488. }
  489. }
  490. };
  491. </script>
  492. <style scoped="scoped" lang="scss">
  493. .s-page {
  494. padding: 20px;
  495. background-color: #ffffff;
  496. }
  497. .page-footer {
  498. height: 70px;
  499. }
  500. .footer {
  501. position: fixed;
  502. bottom: 0;
  503. left: 0;
  504. z-index: 1;
  505. width: 100%;
  506. background: #fff;
  507. padding: 15px 40px;
  508. box-sizing: border-box;
  509. transition: all 0.28s;
  510. text-align: right;
  511. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  512. &.hideSidebar {
  513. margin-left: 54px;
  514. width: calc(100vw - 54px);
  515. }
  516. &.openSidebar {
  517. margin-left: 210px;
  518. width: calc(100vw - 210px);
  519. }
  520. .tips {
  521. font-size: 12px;
  522. color: red;
  523. margin-top: 10px;
  524. }
  525. }
  526. </style>