attachmentSalesOrderDetail.vue 19 KB

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