auxiliarySalesOrderDetail.vue 35 KB

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