attachmentSalesOrderDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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="12">
  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="师傅姓名" prop="worker" :required="true">
  41. <el-select v-model="formData.worker" :disabled="formType == 2" 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" :disabled="formType == 2" 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" :disabled="formType == 2" 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" :disabled="formType == 2" 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" :disabled="formType == 2" 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" :disabled="formType == 2" 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" v-if="formData.flag == 'SAVE' || formType==0" 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 || formType == 2" 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 || formType == 2" 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="销售金额" >
  154. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.goods.price">
  155. {{(scope.row.goods.price * 100) * scope.row.salesQty / 100}}
  156. </template>
  157. </el-table-column>
  158. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  159. <el-table-column label="操作" align="right" width="140">
  160. <template slot-scope="scope" v-if="formType != 2">
  161. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  162. <el-button size="mini" type="danger" @click="dataList.splice(scope.$index,1)">删除</el-button>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. </div>
  167. </el-card>
  168. <div class="page-footer">
  169. <div class="footer">
  170. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  171. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  172. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认收货</el-button>
  173. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  174. <el-button size="small" type="info" @click="goBack">返回</el-button>
  175. </div>
  176. </div>
  177. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  178. <h3 style="text-align: center;">扫二维码支付</h3>
  179. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  180. <div
  181. ref="payQRCode"
  182. style="display: flex; justify-content: center;"
  183. />
  184. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  185. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  186. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  187. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  188. </div>
  189. </el-dialog>
  190. </div>
  191. </template>
  192. <script>
  193. import { getWebsit } from "@/api/customerManagement";
  194. import QRCode from "qrcodejs2";
  195. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  196. export default {
  197. props: ['id','title','formType'],
  198. data() {
  199. return {
  200. dataList: [],
  201. websitList: [],
  202. workerList: [],
  203. isPay: false,
  204. is_submit: true,
  205. payCodeUrl: '',
  206. formData: {
  207. websit: {},
  208. websitId: '',
  209. websitName: '',
  210. file_url: [],
  211. salesId: '',
  212. flag: '',
  213. createBy: '',
  214. createTime: '',
  215. confirmBy: '',
  216. confirmTime: '',
  217. worker: {},
  218. workerName: '',
  219. workerId: '',
  220. idcard: '',
  221. phone: '',
  222. source: '',
  223. payType: '',
  224. remark: ''
  225. },
  226. isEdit: 0,
  227. timer: '',
  228. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  229. rules: {
  230. websitId: [
  231. { required: true, message: '请选择网点', trigger: 'change' }
  232. ],
  233. worker: [
  234. { required: true, message: '请选择师傅', trigger: 'change' }
  235. ],
  236. source: [
  237. { required: true, message: '请选择订单来源', trigger: 'change' }
  238. ],
  239. payType: [
  240. { required: true, message: '请选择订单来源', trigger: 'change' }
  241. ],
  242. idcard: [
  243. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  244. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  245. ],
  246. phone: [
  247. { required: true, message: '请输入师傅联系电话', trigger: 'blur' },
  248. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  249. ],
  250. }
  251. };
  252. },
  253. computed: {},
  254. created() {
  255. if(this.id){
  256. this.getDetail()
  257. }
  258. this.getWebsit()
  259. },
  260. methods: {
  261. // 返回
  262. goBack() {
  263. this.$emit('back');
  264. },
  265. async getDetail(){
  266. const that = this
  267. getDetail({salesId: this.id}).then(res => {
  268. this.formData.flag = res.data.flag
  269. this.formData.websit = {websitId: res.data.websitId,name: res.data.websitName}
  270. this.formData.websitId = res.data.websitId
  271. this.formData.websitName = res.data.websitName
  272. this.getWorker()
  273. this.formData.salesId = res.data.salesId
  274. this.formData.createBy = res.data.createBy
  275. this.formData.createTime = res.data.createTime
  276. this.formData.confirmBy = res.data.confirmBy
  277. this.formData.confirmTime = res.data.confirmTime
  278. this.formData.worker = {nickName: res.data.workerName,userId: res.data.workerId}
  279. this.formData.workerName = res.data.workerName
  280. this.formData.workerId = res.data.workerId
  281. this.formData.idcard = res.data.identity
  282. this.formData.phone = res.data.workerMobile
  283. this.formData.source = res.data.source
  284. this.formData.payType = res.data.payType
  285. this.formData.remark = res.data.remark
  286. res.data.items.forEach(item=>{
  287. that.getGoods(item.goodsName,1).then(ress => {
  288. item.goods = {...ress.data,oldPrice:ress.data.price}
  289. item.goodsList = [{...ress.data,oldPrice:ress.data.price}]
  290. })
  291. })
  292. setTimeout(()=>{
  293. this.dataList = res.data.items
  294. },200)
  295. console.log(this.dataList)
  296. })
  297. },
  298. getWebsit(){
  299. getWebsit({type: 'C'}).then(res => {
  300. this.websitList = res.data
  301. })
  302. },
  303. changeWebsit(e){
  304. this.formData.websitId = e.websitId
  305. this.formData.websitName = e.name
  306. this.getWorker()
  307. },
  308. async getGoods(goodsName,type){
  309. const that = this
  310. if(type == 1){
  311. return new Promise((resolve, reject) => {
  312. getGoods({websitId: this.formData.websitId,type: 'P',goodsName: goodsName}).then(res => {
  313. resolve({
  314. data: res.data[0]
  315. })
  316. })
  317. })
  318. }else{
  319. getGoods({websitId: this.formData.websitId,type: 'P'}).then(res => {
  320. that.dataList[that.isEdit].goodsList = res.data
  321. console.log(this.dataList)
  322. })
  323. }
  324. },
  325. getWorker(){
  326. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  327. this.workerList = res.data.records
  328. })
  329. },
  330. changeWorker(e){
  331. this.formData.idcard = e.idCard
  332. this.formData.phone = e.mobile
  333. this.formData.workerId = e.userId
  334. this.formData.workerName = e.nickName
  335. },
  336. workerBlur(e){
  337. this.formData.worker = e.target.value
  338. this.$forceUpdate()
  339. },
  340. changeGoods(e){
  341. console.log(e)
  342. this.dataList[this.isEdit].goodsId = e.goodsId
  343. this.dataList[this.isEdit].goodsName = e.goodsName
  344. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  345. this.dataList[this.isEdit].brandRelaName = e.brandRelaName
  346. this.dataList[this.isEdit].productRelaName = e.productRelaName
  347. this.dataList[this.isEdit].price = e.price
  348. this.dataList[this.isEdit].goodsCode = e. goodsCode
  349. this.dataList[this.isEdit].qty = e.qty
  350. },
  351. add(){
  352. if(this.dataList.length != 0){this.isEdit += 1}
  353. this.dataList.push({
  354. goodsList: [],
  355. goods: {},
  356. goodsId: '',
  357. goodsName: '',
  358. goodsSalesUnit: '',
  359. brandRelaName: '',
  360. productRelaName: '',
  361. goodsCode: '',
  362. price: '',
  363. saleAmount: '',
  364. salesQty: 1,
  365. qty: '',
  366. goodsType: 'P'
  367. })
  368. this.getGoods()
  369. },
  370. submit(){
  371. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  372. confirmButtonText: '确定',
  373. cancelButtonText: '取消',
  374. type: 'warning'
  375. }).then(() => {
  376. submit({
  377. salesId: this.formData.salesId
  378. }).then(res => {
  379. if(res.code == 200){
  380. this.$message.success('提交成功!')
  381. if(this.formData.payType == 'WECHAT'){
  382. this.wxPay()
  383. }else{
  384. this.goBack()
  385. }
  386. }
  387. })
  388. });
  389. },
  390. confirm(){
  391. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  392. confirmButtonText: '确定',
  393. cancelButtonText: '取消',
  394. type: 'warning'
  395. }).then(() => {
  396. confirm({
  397. salesId: this.formData.salesId
  398. }).then(res => {
  399. if(res.code == 200){
  400. this.$message.success('审核成功!')
  401. this.goBack()
  402. }
  403. })
  404. });
  405. },
  406. checkPay(){
  407. this.timer = setInterval(()=>{
  408. getDetail({salesId: this.id}).then(res => {
  409. if(res.data.payFlag == 'YES'){
  410. this.clear()
  411. this.$message.success('支付成功!')
  412. this.goBack()
  413. }
  414. })
  415. },3000)
  416. },
  417. clear(){
  418. clearInterval(this.timer)
  419. },
  420. wxPay(){
  421. if(!this.is_submit){
  422. return false
  423. }
  424. this.is_submit = false
  425. setTimeout(()=>{
  426. this.is_submit = true
  427. },3000)
  428. getCode({
  429. salesId: this.formData.salesId
  430. }).then(res => {
  431. if(res.code == 200){
  432. this.payCodeUrl = res.data.codeUrl
  433. this.isPay = true
  434. this.$nextTick(() => {
  435. this.payUrl = res.data.codeUrl;
  436. new QRCode(this.$refs.payQRCode, {
  437. text: res.data.codeUrl,
  438. width: 200,
  439. height: 200,
  440. colorDark: "#333333", // 二维码颜色
  441. colorLight: "#ffffff", // 二维码背景色
  442. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  443. });
  444. this.checkPay()
  445. });
  446. }
  447. })
  448. },
  449. save(){
  450. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  451. if (valid) {
  452. if(this.formType == 0){
  453. add({
  454. goodsType: 'P',
  455. source: this.formData.source,
  456. payType: this.formData.payType,
  457. remark: this.formData.remark,
  458. websitId: this.formData.websitId,
  459. websitName: this.formData.websitName,
  460. workerName: this.formData.workerName,
  461. workerId: this.formData.workerId,
  462. identity: this.formData.idcard,
  463. workerMobile: this.formData.phone,
  464. items: this.dataList
  465. }).then(res => {
  466. if(res.code == 200){
  467. this.$message.success('提交成功!')
  468. this.goBack()
  469. }
  470. })
  471. }else if(this.formType == 1){
  472. edit({
  473. salesId: this.formData.salesId,
  474. goodsType: 'P',
  475. source: this.formData.source,
  476. payType: this.formData.payType,
  477. remark: this.formData.remark,
  478. websitId: this.formData.websitId,
  479. websitName: this.formData.websitName,
  480. workerName: this.formData.workerName,
  481. workerId: this.formData.workerId,
  482. identity: this.formData.idcard,
  483. workerMobile: this.formData.phone,
  484. items: this.dataList
  485. }).then(res => {
  486. if(res.code == 200){
  487. this.dataList = []
  488. this.$message.success('提交成功!')
  489. this.goBack()
  490. }
  491. })
  492. }
  493. }
  494. })
  495. }
  496. }
  497. };
  498. </script>
  499. <style scoped="scoped" lang="scss">
  500. .s-page {
  501. padding: 20px;
  502. background-color: #ffffff;
  503. }
  504. .page-footer {
  505. height: 70px;
  506. }
  507. .footer {
  508. position: fixed;
  509. bottom: 0;
  510. left: 0;
  511. z-index: 1;
  512. width: 100%;
  513. background: #fff;
  514. padding: 15px 40px;
  515. box-sizing: border-box;
  516. transition: all 0.28s;
  517. text-align: right;
  518. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  519. &.hideSidebar {
  520. margin-left: 54px;
  521. width: calc(100vw - 54px);
  522. }
  523. &.openSidebar {
  524. margin-left: 210px;
  525. width: calc(100vw - 210px);
  526. }
  527. .tips {
  528. font-size: 12px;
  529. color: red;
  530. margin-top: 10px;
  531. }
  532. }
  533. </style>