auxiliarySalesOrderDetail.vue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  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="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="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. <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" :disabled="formData.flag != 'SAVE' && formType!=0" v-model="formData.remark" 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.parentCategory" value-key="categoryId" @change="changeMain" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  265. <el-option
  266. v-for="item in mainList"
  267. :key="item.categoryId"
  268. :label="item.categoryName"
  269. :value="item">
  270. </el-option>
  271. </el-select>
  272. </template>
  273. </el-table-column>
  274. <el-table-column label="小类名称" align="center">
  275. <template slot-scope="scope">
  276. <el-select v-model="scope.row.goodsCategory" @change="changeSmall" @focus="()=>{
  277. if(!scope.row.parentCategory){return this.$message.warning('请先选择大类!');}
  278. }" :disabled="isEdit != scope.$index || formType == 2" value-key="categoryId" placeholder="请选择" style="width: 100%;">
  279. <el-option
  280. v-for="item in scope.row.parentCategory.items"
  281. :key="item.categoryId"
  282. :label="item.categoryName"
  283. :value="item">
  284. </el-option>
  285. </el-select>
  286. </template>
  287. </el-table-column>
  288. <el-table-column label="辅材名称" align="center">
  289. <template slot-scope="scope">
  290. <el-select v-model="scope.row.goods" @change="changeGoods" value-key="goodsId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  291. <el-option
  292. v-for="item in scope.row.goodsList"
  293. :key="item.goodsId"
  294. :label="item.goodsName"
  295. :value="item">
  296. </el-option>
  297. </el-select>
  298. </template>
  299. </el-table-column>
  300. <el-table-column prop="goods.goodsSalesUnit" align="center" label="单位" ></el-table-column>
  301. <el-table-column prop="" align="center" label="数量" >
  302. <template slot-scope="scope">
  303. <el-input type="number" v-model="scope.row.salesQty" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  304. </template>
  305. </el-table-column>
  306. <el-table-column prop="goods.goodsCode" align="center" label="商品代码"></el-table-column>
  307. <el-table-column prop="goods.goodsSpecification" align="center" label="规格型号"></el-table-column>
  308. <el-table-column prop="" align="center" label="销售价格">
  309. <template slot-scope="scope">
  310. <el-input type="number" v-model="scope.row.price" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  311. </template>
  312. </el-table-column>
  313. <el-table-column prop="" align="center" label="销售金额" >
  314. <template slot-scope="scope" v-if="scope.row.salesQty && scope.row.price">
  315. {{((scope.row.price * 100) * scope.row.salesQty / 100).toFixed(2)}}
  316. </template>
  317. </el-table-column>
  318. <el-table-column prop="goods.qty" align="center" label="库存数量"></el-table-column>
  319. <el-table-column label="操作" align="right" width="140">
  320. <template slot-scope="scope" v-if="formType != 2">
  321. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  322. <el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
  323. </template>
  324. </el-table-column>
  325. </el-table>
  326. </div>
  327. </el-card>
  328. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0 && formData.flag == 'SAVE'">
  329. <div slot="header" class="clearfix">
  330. <span>收款信息</span>
  331. </div>
  332. <div class="mymain-container">
  333. <el-form ref="formData1" :rules="rules1" :model="formData1" label-width="110px" size="small" label-position="left">
  334. <el-row :gutter="20" justify="start">
  335. <el-col :span="24">
  336. <el-form-item label="收款金额" prop="price">
  337. <el-input type="text" style="width: 30%" v-model="formData1.price" placeholder="请输入"></el-input>
  338. <span style="color: #FF8F47;margin-left: 10px">注:操作【提交】时,系统方可记录收款信息</span>
  339. </el-form-item>
  340. </el-col>
  341. <el-col :span="24">
  342. <el-form-item label="收款凭证">
  343. <ImageUpload :fileList="formData1.fileUrl" :limit="1" :isEdit="formType !== 2" />
  344. </el-form-item>
  345. </el-col>
  346. <el-col :span="24">
  347. <el-form-item label="备注">
  348. <el-input type="textarea" :rows="4" v-model="formData1.remark" placeholder="请输入"></el-input>
  349. </el-form-item>
  350. </el-col>
  351. </el-row>
  352. </el-form>
  353. </div>
  354. </el-card>
  355. <el-card class="box-card" v-if="formData.salesType == '工程' && formType != 0">
  356. <div slot="header" class="clearfix">
  357. <span>收款记录</span>
  358. </div>
  359. <div class="table">
  360. <el-table :data="collectionList" element-loading-text="Loading" border fit highlight-current-row stripe>
  361. <el-table-column prop="status" label="收款结果" align="center">
  362. <template slot-scope="scope">
  363. {{scope.row.status == 'NO'?'未付款':scope.row.status == 'WAIT'?'部分付款':scope.row.status == 'OK'?'已完成':''}}
  364. </template>
  365. </el-table-column>
  366. <el-table-column prop="price" label="收款金额" align="center"></el-table-column>
  367. <el-table-column prop="" align="center" label="收款凭证" >
  368. <template slot-scope="scope" v-if="scope.row.urlPrc">
  369. <el-image style="width: 80px;" :src="scope.row.urlPrc" fit="scale-down" :preview-src-list="[scope.row.urlPrc]"></el-image>
  370. </template>
  371. </el-table-column>
  372. <el-table-column prop="remark" label="备注" align="center"></el-table-column>
  373. <el-table-column prop="updateBy" align="center" label="收款人" ></el-table-column>
  374. <el-table-column prop="updateTime" align="center" label="收款时间" ></el-table-column>
  375. </el-table>
  376. </div>
  377. </el-card>
  378. <div class="page-footer">
  379. <div class="footer">
  380. <el-button v-if="formType == 0 || (formType == 1 && formData.flag == 'SAVE')" size="small" type="primary" @click="save()">保存</el-button>
  381. <el-button v-if="formType != 0 && formData.flag == 'SAVE'" size="small" type="primary" @click="submit()">提交</el-button>
  382. <el-button v-if="formData.flag == 'SUBMIT' && formData.payType == 'WECHAT'" size="small" type="primary" @click="wxPay()">微信支付</el-button>
  383. <el-button v-if="formData.flag == 'PAY_NOT_TAKE'" size="small" type="primary" @click="confirm()">确认提货</el-button>
  384. <el-button size="small" type="info" @click="goBack">返回</el-button>
  385. </div>
  386. </div>
  387. <el-dialog title="微信支付" :visible.sync="isPay" width="50%" :close-on-click-modal="false" :modal-append-to-body="false" @close="payCodeUrl = '';clear()">
  388. <h3 style="text-align: center;">扫二维码支付</h3>
  389. <!-- <el-image :src="payCodeUrl" fit="fit"></el-image> -->
  390. <div
  391. ref="payQRCode"
  392. style="display: flex; justify-content: center;"
  393. />
  394. <div style="color: #EA8000;text-align: center;margin-top: 20px;">注:支付成功后,方可操作确认提货!</div>
  395. <div style="display: flex;justify-content: flex-end;margin-top: 30px;">
  396. <el-button size="mini" type="text" @click="isPay = false;clear()">取消</el-button>
  397. <el-button size="small" type="primary" @click="isPay = false;getDetail()">确定</el-button>
  398. </div>
  399. </el-dialog>
  400. </div>
  401. </template>
  402. <script>
  403. import { getWebsit } from "@/api/customerManagement";
  404. import QRCode from "qrcodejs2";
  405. import { lbsAmapRegion } from '@/api/common.js'
  406. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  407. import ImageUpload from '@/components/file-upload'
  408. import { getWorker, getCategory, getGoods, getDetail, add, edit, confirm, submit, getCode, getProject, getProjectCollectionList } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  409. import { storageListPageV2 } from '@/api/storage.js'
  410. export default {
  411. components: {geographicalPosi,ImageUpload},
  412. props: ['id','title','formType'],
  413. data() {
  414. return {
  415. dataList: [],
  416. websitList: [],
  417. workerList: [],
  418. mainList: [],
  419. projectList: [],
  420. collectionList: [],
  421. warehouseList: [],
  422. isPay: false,
  423. payCodeUrl: '',
  424. formData: {
  425. websit: {},
  426. websitId: '',
  427. websitName: '',
  428. file_url: [],
  429. salesId: '',
  430. flag: '',
  431. createBy: '',
  432. createTime: '',
  433. confirmBy: '',
  434. confirmTime: '',
  435. worker: {},
  436. workerName: '',
  437. workerId: '',
  438. identity: '',
  439. workerMobile: '',
  440. orderSource: 'SELF',
  441. payType: '',
  442. remark: '',
  443. totalAmount: '',
  444. buyPeople: 'WORKER',
  445. salesType: '零售',
  446. province: '',
  447. provinceId: '',
  448. city: '',
  449. cityId: '',
  450. area: '',
  451. areaId: '',
  452. street: '',
  453. streetId: '',
  454. address: '',
  455. lat: '',
  456. lng: '',
  457. project: {},
  458. orderEnginBaseId: '',
  459. storage: null,
  460. storageId: '',
  461. storageName: '',
  462. },
  463. formData1: {
  464. price: '',
  465. remark: '',
  466. fileUrl: []
  467. },
  468. provinceList: [],
  469. cityList: [],
  470. areaList: [],
  471. streetList: [],
  472. isEdit: 0,
  473. is_submit: true,
  474. timer: '',
  475. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  476. rules: {
  477. websitId: [
  478. { required: true, message: '请选择网点', trigger: 'change' }
  479. ],
  480. worker: [
  481. { required: true, message: '请选择师傅', trigger: 'change' }
  482. ],
  483. orderSource: [
  484. { required: true, message: '请选择订单来源', trigger: 'change' }
  485. ],
  486. payType: [
  487. { required: true, message: '请选择订单来源', trigger: 'change' }
  488. ],
  489. identity: [
  490. { required: true, message: '请输入师傅身份证', trigger: 'blur' },
  491. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  492. ],
  493. workerMobile: [
  494. { required: true, message: `请输入联系电话`, trigger: 'blur' },
  495. { required: true, message: `请输入联系电话`, trigger: 'change' },
  496. { pattern:/^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  497. ],
  498. workerName: [
  499. { required: true, message: '请输入客户姓名', trigger: 'blur' }
  500. ],
  501. storage: [
  502. { required: true, message: `请选择入库仓库`, trigger: 'change' },
  503. ]
  504. },
  505. rules1: {
  506. price: [
  507. { pattern:/^[1-9]\d*(\.\d+)?$|^0\.[1-9]\d*$/, message: '请输入大于0的数字', trigger: 'blur' }
  508. ],
  509. }
  510. };
  511. },
  512. computed: {},
  513. created() {
  514. if(this.id){
  515. this.getDetail()
  516. }
  517. this.getinitlbslist()
  518. this.getWebsit()
  519. this.getProject()
  520. },
  521. methods: {
  522. // 返回
  523. goBack() {
  524. this.$emit('back');
  525. },
  526. async getDetail(){
  527. const that = this
  528. getDetail({salesId: this.id}).then( async res => {
  529. Object.assign(this.formData, res.data, {
  530. websit: {websitId: res.data.websitId,name: res.data.websitName},
  531. worker: {nickName: res.data.workerName,userId: res.data.workerId},
  532. 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},
  533. storage: {
  534. storageId: res.data.storageId
  535. }
  536. })
  537. this.getWorker()
  538. this.getCategory(res.data.websitId)
  539. this.getWarehouseList(res.data.websitId)
  540. if(res.data.salesType == '工程'){
  541. this.getProjectCollectionList(res.data.orderEnginBaseId)
  542. }
  543. this.formData.remark = res.data.remark
  544. for(var item of res.data.items){
  545. item.parentCategory = {categoryId: item.parentCategoryId,categoryName: item.parentCategoryName, items: [{categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}]}
  546. item.goodsCategory = {categoryId: item.goodsCategoryId,categoryName: item.goodsCategoryName}
  547. var ress = await that.getGoods(item.goodsCategoryId,item.goodsName, 1)
  548. item.goods = ress.data
  549. item.goodsList = ress.data ? [ress.data] : []
  550. }
  551. this.dataList = res.data.items
  552. })
  553. },
  554. getWebsit(){
  555. getWebsit({type: 'C'}).then(res => {
  556. this.websitList = res.data
  557. })
  558. },
  559. changeWebsit(e){
  560. this.formData.websitId = e.websitId
  561. this.formData.websitName = e.name
  562. this.getWorker()
  563. this.getCategory(e.websitId)
  564. this.getWarehouseList(e.websitId)
  565. },
  566. getCategory(websitId){
  567. getCategory({websitId}).then(res => {
  568. this.mainList = res.data
  569. })
  570. },
  571. toAddProject(){
  572. this.$router.push({
  573. name: 'basicEngineeringData'
  574. })
  575. },
  576. getProject(){
  577. getProject({
  578. pageNum: 1,
  579. pageSize: -1,
  580. params:[]
  581. }).then(res => {
  582. this.projectList = res.data.records
  583. })
  584. },
  585. getWarehouseList(websitId){
  586. if(!websitId){return this.warehouseList = []}
  587. storageListPageV2({
  588. pageNum: 1,
  589. pageSize: -1,
  590. params: [{param: "a.type", compare: "like", value: "辅材"},{param: "a.status", compare: "=", value: "true"},{param: "a.websit_id", compare: "=", value: websitId}]
  591. }).then(res => {
  592. this.warehouseList = res.data.records
  593. })
  594. },
  595. getProjectCollectionList(orderEnginBaseId){
  596. getProjectCollectionList({orderEnginBaseId,goodsType: 'M'}).then(res => {
  597. this.collectionList = res.data
  598. })
  599. },
  600. async getGoods(categoryId,goodsName,type){
  601. // if(!this.formData.storageId){return this.$message.warning('请先选择出库仓库!')}
  602. const that = this
  603. if(type == 1){
  604. return new Promise((resolve, reject) => {
  605. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',goodsName: goodsName,orderEnginBaseId: this.formData.orderEnginBaseId,saleType: this.formData.salesType,storageId: this.formData.storageId}).then(res => {
  606. resolve({
  607. data: res.data[0]
  608. })
  609. })
  610. })
  611. }else{
  612. getGoods({websitId: this.formData.websitId,categoryId: categoryId,type: 'M',orderEnginBaseId: this.formData.orderEnginBaseId,saleType: this.formData.salesType,storageId: this.formData.storageId}).then(res => {
  613. that.dataList[that.isEdit].goodsList = res.data
  614. })
  615. }
  616. },
  617. getWorker(){
  618. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  619. this.workerList = res.data.records
  620. })
  621. },
  622. changeWorker(e){
  623. this.formData.identity = e.idCard
  624. this.formData.workerMobile = e.mobile
  625. this.formData.workerId = e.userId
  626. this.formData.workerName = e.nickName
  627. },
  628. workerBlur(e){
  629. this.formData.worker = e.target.value
  630. this.$forceUpdate()
  631. },
  632. changeMain(e){
  633. this.dataList[this.isEdit].goodsList = [],
  634. this.dataList[this.isEdit].parentCategory = e,
  635. this.dataList[this.isEdit].parentCategoryId = e.categoryId,
  636. this.dataList[this.isEdit].parentCategoryName = e.categoryName,
  637. this.dataList[this.isEdit].goodsCategory = {},
  638. this.dataList[this.isEdit].goodsCategoryName = '',
  639. this.dataList[this.isEdit].goodsCategoryId = '',
  640. this.dataList[this.isEdit].goods = {},
  641. this.dataList[this.isEdit].goodsId = '',
  642. this.dataList[this.isEdit].goodsName = '',
  643. this.dataList[this.isEdit].goodsSalesUnit = '',
  644. this.dataList[this.isEdit].goodsSpecification = '',
  645. this.dataList[this.isEdit].goodsCode = '',
  646. this.dataList[this.isEdit].price = '',
  647. this.dataList[this.isEdit].saleAmount = '',
  648. this.dataList[this.isEdit].salesQty = ''
  649. this.dataList[this.isEdit].qty = '',
  650. this.dataList[this.isEdit].goodsType = 'M'
  651. },
  652. async changeSmall(e){
  653. this.dataList[this.isEdit].goods = {},
  654. this.dataList[this.isEdit].goodsId = '',
  655. this.dataList[this.isEdit].goodsName = '',
  656. this.dataList[this.isEdit].goodsSalesUnit = '',
  657. this.dataList[this.isEdit].goodsSpecification = '',
  658. this.dataList[this.isEdit].goodsCode = '',
  659. this.dataList[this.isEdit].price = '',
  660. this.dataList[this.isEdit].saleAmount = '',
  661. this.dataList[this.isEdit].salesQty = ''
  662. this.dataList[this.isEdit].qty = '',
  663. this.dataList[this.isEdit].goodsCategoryId = e.categoryId
  664. this.dataList[this.isEdit].goodsCategoryName = e.categoryName
  665. // if(!this.formData.storageId){return this.$message.warning('请先选择出库仓库!')}
  666. getGoods({websitId: this.formData.websitId,categoryId: e.categoryId,type: 'M',orderEnginBaseId: this.formData.orderEnginBaseId,saleType: this.formData.salesType,storageId: this.formData.storageId}).then(res => {
  667. this.dataList[this.isEdit].goodsList = res.data
  668. })
  669. },
  670. changeGoods(e){
  671. console.log(e)
  672. this.dataList[this.isEdit].goodsId = e.goodsId
  673. this.dataList[this.isEdit].goodsName = e.goodsName
  674. this.dataList[this.isEdit].goodsSalesUnit = e.goodsSalesUnit
  675. this.dataList[this.isEdit].goodsSpecification = e.goodsSpecification
  676. this.dataList[this.isEdit].price = e.price
  677. this.dataList[this.isEdit].goodsCode = e. goodsCode
  678. this.dataList[this.isEdit].qty = e.qty
  679. this.dataList[this.isEdit].itemSourceType = e.itemSourceType
  680. this.dataList[this.isEdit].itemSourceId = e.itemSourceId
  681. this.dataList[this.isEdit].normType = e.normType
  682. },
  683. add(){
  684. if(this.dataList.length != 0){this.isEdit = 0}
  685. this.dataList.unshift({
  686. goodsList: [],
  687. parentCategory: {},
  688. parentCategoryId: '',
  689. parentCategoryName: '',
  690. goodsCategory: {},
  691. goodsCategoryName: '',
  692. goodsCategoryId: '',
  693. goods: {},
  694. goodsId: '',
  695. goodsName: '',
  696. goodsSalesUnit: '',
  697. goodsSpecification: '',
  698. goodsCode: '',
  699. price: '',
  700. saleAmount: '',
  701. salesQty: 1,
  702. qty: '',
  703. goodsType: 'M',
  704. itemSourceType: '',
  705. itemSourceId: '',
  706. normType: ''
  707. })
  708. },
  709. del(index){
  710. if(index <= 1){this.isEdit == 0}else{this.isEdit -= 1}
  711. this.dataList.splice(index,1)
  712. },
  713. confirmSubmit(){
  714. if(this.formData1.price && !/^[1-9]\d*(\.\d+)?$|^0\.[0-9]\d*$/.test(this.formData1.price)){
  715. return this.$message.warning('请输入大于0的数字!')
  716. }
  717. this.$confirm(`请确定是否提交订单, 是否继续?`, '提示', {
  718. confirmButtonText: '确定',
  719. cancelButtonText: '取消',
  720. type: 'warning'
  721. }).then(() => {
  722. submit({
  723. salesId: this.formData.salesId,
  724. price: this.formData1.price,
  725. urlPrc: this.formData1.fileUrl.length> 0 ?this.formData1.fileUrl[0].url: '',
  726. remark: this.formData1.remark
  727. }).then(res => {
  728. if(res.code == 200){
  729. this.$message.success('提交成功!')
  730. if(this.formData.payType == 'WECHAT'){
  731. this.wxPay()
  732. }else{
  733. this.goBack()
  734. }
  735. }
  736. })
  737. });
  738. },
  739. submit(){
  740. const that = this
  741. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  742. if (valid) {
  743. edit({
  744. salesId: this.formData.salesId,
  745. goodsType: 'M',
  746. orderSource: this.formData.orderSource,
  747. payType: this.formData.payType,
  748. remark: this.formData.remark,
  749. websitId: this.formData.websitId,
  750. websitName: this.formData.websitName,
  751. workerName: this.formData.workerName,
  752. workerId: this.formData.workerId,
  753. identity: this.formData.identity,
  754. workerMobile: this.formData.workerMobile,
  755. buyPeople: this.formData.buyPeople,
  756. items: this.dataList,
  757. orderEnginBaseId: this.formData.orderEnginBaseId,
  758. salesType: this.formData.salesType,
  759. storageId: this.formData.storageId,
  760. storageName: this.formData.storageName,
  761. }).then(res => {
  762. if(res.code == 200){
  763. this.$nextTick(() => {
  764. that.confirmSubmit()
  765. })
  766. }
  767. })
  768. }
  769. })
  770. },
  771. confirm(){
  772. if(!this.formData.storageId){return this.$message.warning('请先选择出库仓库!')}
  773. this.$confirm(`请确定是否确认提货, 是否继续?`, '提示', {
  774. confirmButtonText: '确定',
  775. cancelButtonText: '取消',
  776. type: 'warning'
  777. }).then(() => {
  778. confirm({
  779. salesId: this.formData.salesId,
  780. storageId: this.formData.storageId
  781. }).then(res => {
  782. if(res.code == 200){
  783. this.$message.success('审核成功!')
  784. this.goBack()
  785. }
  786. })
  787. });
  788. },
  789. checkPay(){
  790. this.timer = setInterval(()=>{
  791. getDetail({salesId: this.id}).then(res => {
  792. if(res.data.payFlag == 'YES'){
  793. this.$refs.payQRCode.innerHTML = '';
  794. this.clear()
  795. this.$message.success('支付成功!')
  796. this.goBack()
  797. }
  798. })
  799. },3000)
  800. },
  801. clear(){
  802. clearInterval(this.timer)
  803. },
  804. wxPay(){
  805. if(!this.is_submit){
  806. return false
  807. }
  808. this.is_submit = false
  809. setTimeout(()=>{
  810. this.is_submit = true
  811. },2000)
  812. getCode({
  813. salesId: this.formData.salesId
  814. }).then(res => {
  815. if(res.code == 200){
  816. this.payCodeUrl = res.data.codeUrl
  817. this.$refs.payQRCode.innerHTML = '';
  818. this.$nextTick(() => {
  819. this.payUrl = res.data.codeUrl;
  820. new QRCode(this.$refs.payQRCode, {
  821. text: res.data.codeUrl,
  822. width: 200,
  823. height: 200,
  824. colorDark: "#333333", // 二维码颜色
  825. colorLight: "#ffffff", // 二维码背景色
  826. correctLevel: QRCode.CorrectLevel.L // 容错率,L/M/H
  827. });
  828. this.checkPay()
  829. });
  830. }
  831. })
  832. this.isPay = true
  833. },
  834. save(){
  835. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  836. if (valid) {
  837. if(this.formType == 0){
  838. add({
  839. goodsType: 'M',
  840. orderSource: this.formData.orderSource,
  841. payType: this.formData.payType,
  842. remark: this.formData.remark,
  843. websitId: this.formData.websitId,
  844. websitName: this.formData.websitName,
  845. workerName: this.formData.workerName,
  846. workerId: this.formData.workerId,
  847. identity: this.formData.identity,
  848. workerMobile: this.formData.workerMobile,
  849. buyPeople: this.formData.buyPeople,
  850. items: this.dataList,
  851. orderEnginBaseId: this.formData.orderEnginBaseId,
  852. salesType: this.formData.salesType,
  853. storageId: this.formData.storageId,
  854. storageName: this.formData.storageName,
  855. }).then(res => {
  856. if(res.code == 200){
  857. this.$message.success('提交成功!')
  858. this.goBack()
  859. }
  860. })
  861. }else if(this.formType == 1){
  862. edit({
  863. salesId: this.formData.salesId,
  864. goodsType: 'M',
  865. orderSource: this.formData.orderSource,
  866. payType: this.formData.payType,
  867. remark: this.formData.remark,
  868. websitId: this.formData.websitId,
  869. websitName: this.formData.websitName,
  870. workerName: this.formData.workerName,
  871. workerId: this.formData.workerId,
  872. identity: this.formData.identity,
  873. workerMobile: this.formData.workerMobile,
  874. buyPeople: this.formData.buyPeople,
  875. items: this.dataList,
  876. orderEnginBaseId: this.formData.orderEnginBaseId,
  877. salesType: this.formData.salesType,
  878. storageId: this.formData.storageId,
  879. storageName: this.formData.storageName,
  880. }).then(res => {
  881. if(res.code == 200){
  882. this.dataList = []
  883. this.$message.success('提交成功!')
  884. this.goBack()
  885. }
  886. })
  887. }
  888. }
  889. })
  890. },
  891. changeSale(){
  892. this.formData.buyPeople = 'CUSTOMER'
  893. },
  894. getinitlbslist() {
  895. // 初始化请求省市区街道下拉选项数据
  896. lbsAmapRegion({ pid: 0 }).then(res => {
  897. this.provinceList = res.data
  898. // 创建工单时获取ip地址定位赋值
  899. if (!this.id && this.$IpAdd.province) {
  900. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  901. if (item) {
  902. this.formData.provinceId = item.id
  903. this.formData.province = item.name
  904. }
  905. }
  906. if (this.formData.provinceId) {
  907. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  908. this.cityList = res.data
  909. // 创建工单时获取ip地址定位赋值
  910. if (!this.id && this.$IpAdd.city) {
  911. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  912. if (item2) {
  913. this.formData.cityId = item2.id
  914. this.formData.city = item2.name
  915. }
  916. }
  917. if (this.formData.cityId) {
  918. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  919. this.areaList = res.data
  920. })
  921. }
  922. if (this.formData.areaId) {
  923. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  924. this.streetList = res.data
  925. })
  926. }
  927. })
  928. }
  929. })
  930. },
  931. selectAddress(data){
  932. this.formData.lng = data.center[0]
  933. this.formData.lat = data.center[1]
  934. // 获取定位的省市区街道
  935. var { province, city, district, township } = data.data.addressComponent
  936. // 获取选中省名称id
  937. var { id, name } = this.provinceList.find(item => item.name === province)
  938. this.formData.provinceId = id
  939. this.formData.province = name
  940. // 请求市选项
  941. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  942. // 赋值市选项
  943. this.cityList = res.data
  944. // 获取选中市名称id
  945. var { id, name } = res.data.find(item => item.name === city)
  946. this.formData.cityId = id
  947. this.formData.city = name
  948. // 请求区选项
  949. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  950. // 赋值区选项
  951. this.areaList = res.data
  952. // 获取选中区名称id
  953. var { id, name } = res.data.find(item => item.name === district)
  954. this.formData.areaId = id
  955. this.formData.area = name
  956. // 请求街道选项
  957. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  958. // 赋值街道选项
  959. this.streetList = res.data
  960. // 获取选中街道名称id
  961. var { id, name } = res.data.find(item => item.name === township)
  962. this.formData.streetId = id
  963. this.formData.street = name
  964. // 赋值GPS详细地址
  965. this.formData.address = data.name
  966. })
  967. })
  968. })
  969. },
  970. }
  971. };
  972. </script>
  973. <style scoped="scoped" lang="scss">
  974. .s-page {
  975. padding: 20px;
  976. background-color: #ffffff;
  977. }
  978. .page-footer {
  979. height: 70px;
  980. }
  981. .footer {
  982. position: fixed;
  983. bottom: 0;
  984. left: 0;
  985. z-index: 1;
  986. width: 100%;
  987. background: #fff;
  988. padding: 15px 40px;
  989. box-sizing: border-box;
  990. transition: all 0.28s;
  991. text-align: right;
  992. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  993. &.hideSidebar {
  994. margin-left: 54px;
  995. width: calc(100vw - 54px);
  996. }
  997. &.openSidebar {
  998. margin-left: 210px;
  999. width: calc(100vw - 210px);
  1000. }
  1001. .tips {
  1002. font-size: 12px;
  1003. color: red;
  1004. margin-top: 10px;
  1005. }
  1006. }
  1007. </style>