attachmentSalesOrderDetail.vue 35 KB

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