home_form.vue 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header @back="goBack" :content="listItem ? '编辑':'新增'"></el-page-header>
  4. <div class="main-title">
  5. <div class="title">工程订单</div>
  6. </div>
  7. <el-form ref="mainForm" :model="mainForm" :rules="mainFormRules" label-width="125px" size="small" label-position="right">
  8. <el-row :gutter="20">
  9. <el-col :xs="24" :sm="12" :lg="8">
  10. <el-form-item label="工程订单" prop="orderNum">
  11. <el-input v-model="mainForm.orderNum" placeholder="系统自动生成" disabled></el-input>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  15. <el-form-item label="单据日期" prop="orderDate">
  16. <el-date-picker
  17. v-model="mainForm.orderDate"
  18. disabled
  19. type="date"
  20. value-format="yyyy-MM-dd"
  21. style="width: 100%;"
  22. placeholder="系统自动生成">
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="8">
  27. <el-form-item label="销售类型" prop="saleType">
  28. <el-select v-model="mainForm.saleType" placeholder="选择销售类型" style="width: 100%" clearable @change="changeSaleType">
  29. <el-option v-for="item in salesTypeList" :key="item.id" :label="item.saleName" :value="item.id"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="12" :lg="8">
  34. <el-form-item label="经销商编码" prop="jxsNum">
  35. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :xs="24" :sm="12" :lg="16">
  39. <el-form-item label="经销商名称" prop="jxsName">
  40. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :xs="24" :sm="12" :lg="8">
  44. <el-form-item label="工程登录编号" prop="loginNum">
  45. <div style="display: flex;">
  46. <el-input v-model="mainForm.loginNum" placeholder="请引用工程登录" disabled></el-input>
  47. <el-button style="margin-left: 10px;" @click="openShareDetail">引用</el-button>
  48. </div>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :xs="24" :sm="12" :lg="8">
  52. <el-form-item label="项目类别" prop="enginName">
  53. <el-input v-model="mainForm.enginName" placeholder="请输入项目类别" :disabled="isDealer"></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :xs="24" :sm="12" :lg="8">
  57. <el-form-item label="行业类别" prop="loginType">
  58. <el-input v-model="mainForm.loginType" placeholder="请输入行业类别"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :xs="24" :sm="12" :lg="8">
  62. <el-form-item label="跨区厂编号" prop="factoryNum">
  63. <el-input v-model="mainForm.factoryNum" placeholder="请输入跨区厂编号" :disabled="isDealer"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :xs="24" :sm="12" :lg="8">
  67. <el-form-item label="使用单位" prop="company">
  68. <el-input v-model="mainForm.company" placeholder="请输入使用单位" :disabled="isDealer"></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :xs="24" :sm="12" :lg="8">
  72. <el-form-item label="业务员" prop="salesMan">
  73. <el-select v-model="mainForm.salesMan" placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
  74. <el-option
  75. v-for="item in salesmanList"
  76. :key="item.adminUserId"
  77. :label="item.nickName"
  78. :value="item.adminUserId">
  79. </el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :xs="24" :sm="12" :lg="8">
  84. <el-form-item label="引用记录" prop="refCount">
  85. <el-input v-model="mainForm.refCount" placeholder="请输入引用记录" :disabled="isDealer"></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :xs="24" :sm="12" :lg="8">
  89. <el-form-item label="第几次申报" prop="declareNo">
  90. <el-input v-model="mainForm.declareNo" placeholder="请输入第几次申报" :disabled="isDealer"></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :xs="24" :sm="12" :lg="8">
  94. <el-form-item label="项目类型" prop="projectType">
  95. <el-input v-model="mainForm.projectType" placeholder="请输入项目类型" :disabled="isDealer"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :xs="24" :sm="12" :lg="8">
  99. <el-form-item label="区域" prop="regionWork">
  100. <el-input v-model="mainForm.regionWork" placeholder="请输入区域" :disabled="isDealer"></el-input>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :xs="24" :sm="12" :lg="8">
  104. <el-form-item label="文件编号" prop="fileNum">
  105. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号" :disabled="isDealer"></el-input>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :xs="24" :sm="12" :lg="8">
  109. <el-form-item label="购买单位" prop="refBuyUnitName">
  110. <el-input v-model="mainForm.refBuyUnitName" placeholder="请输入购买单位" :disabled="isDealer"></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :xs="24" :sm="12" :lg="8">
  114. <el-form-item label="联系人" prop="contactMan">
  115. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人"></el-input>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :xs="24" :sm="12" :lg="8">
  119. <el-form-item label="固定电话" prop="tel">
  120. <el-input v-model="mainForm.tel" placeholder="请输入固定电话"></el-input>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :xs="24" :sm="12" :lg="8">
  124. <el-form-item label="移动电话" prop="phone">
  125. <el-input v-model="mainForm.phone" placeholder="请输入移动电话"></el-input>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :xs="24" :sm="16" :lg="16">
  129. <el-form-item label="安装地址" prop="address">
  130. <el-input v-model="mainForm.address" placeholder="请输入安装地址" :disabled="isDealer"></el-input>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :xs="24" :sm="8" :lg="8">
  134. <el-form-item label="保证函" prop="refPromiseProvide">
  135. <el-select v-model="mainForm.refPromiseProvide" placeholder="选择保证函状态" :disabled="isDealer?true:false" size="small" clearable style="width: 100%">
  136. <el-option label="未保证" value="未保证"></el-option>
  137. <el-option label="已保证" value="已保证"></el-option>
  138. </el-select>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :xs="24" :sm="24" :lg="24">
  142. <el-form-item label="项目说明" prop="projectRemark">
  143. <el-input v-model="mainForm.projectRemark" placeholder="请输入项目说明" :disabled="isDealer"></el-input>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :xs="24" :sm="24" :lg="24">
  147. <el-form-item label="其他附件审批意见" prop="refOtherAnnexIdea">
  148. <el-input v-model="mainForm.refOtherAnnexIdea" placeholder="请输入其他附件审批意见" disabled></el-input>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :xs="24" :sm="24" :lg="24" v-if="!isDealer">
  152. <el-form-item label="格力内部备注" prop="greeRemark">
  153. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注"></el-input>
  154. </el-form-item>
  155. </el-col>
  156. <!-- <el-col :xs="24" :sm="24" :lg="24">
  157. <el-form-item label="格力回复" prop="greeReply">
  158. <el-input v-model="mainForm.greeReply" placeholder="请输入格力回复"></el-input>
  159. </el-form-item>
  160. </el-col> -->
  161. <el-col :xs="24" :sm="24" :lg="24">
  162. <el-form-item label="备注" prop="remark">
  163. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :xs="24" :sm="12" :lg="8">
  167. <el-form-item label="制单人" prop="createMan">
  168. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  169. </el-form-item>
  170. </el-col>
  171. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  172. <el-form-item label="制单日期" prop="createDate">
  173. <el-date-picker
  174. v-model="mainForm.createDate"
  175. disabled
  176. type="date"
  177. :default-value="getDate()"
  178. value-format="yyyy-MM-dd"
  179. style="width: 100%;"
  180. placeholder="选择日期">
  181. </el-date-picker>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :xs="24" :sm="24" :lg="24" v-if="mainForm.examineRemark">
  185. <el-form-item label="审批说明" prop="examineRemark">
  186. <el-input v-model="mainForm.examineRemark" placeholder="请输入审批说明" disabled></el-input>
  187. </el-form-item>
  188. </el-col>
  189. </el-row>
  190. </el-form>
  191. <div class="main-title">
  192. <div class="title">货品信息</div>
  193. <div>
  194. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  195. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  196. </el-select>
  197. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  198. <el-divider direction="vertical"></el-divider>
  199. <el-button type="primary" size="small" icon="el-icon-plus" @click="openDialog">添加货品</el-button>
  200. </div>
  201. </div>
  202. <div class="table" style="margin-top: 20px">
  203. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
  204. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  205. <!-- <el-table-column align="center" label="引用记录" prop="useRefCount" min-width="160" show-overflow-tooltip></el-table-column> -->
  206. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
  207. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  208. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  209. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  210. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  211. <template slot-scope="scope">
  212. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  213. <div v-else>{{scope.row.specification}}</div>
  214. </template>
  215. </el-table-column>
  216. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  217. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  218. <template slot-scope="scope">
  219. <el-input v-model="scope.row.price" size="small" type="number"></el-input>
  220. </template>
  221. </el-table-column>
  222. <el-table-column align="center" label="工程登录数量" prop="enginNum" min-width="120" show-overflow-tooltip></el-table-column>
  223. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  224. <template slot-scope="scope">
  225. <el-input v-model="scope.row.qty" size="small" type="number"></el-input>
  226. </template>
  227. </el-table-column>
  228. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  229. <template slot-scope="scope">
  230. {{scope.row.price * scope.row.qty}}
  231. </template>
  232. </el-table-column>
  233. <el-table-column align="center" label="返利类型" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  234. <template slot-scope="scope">
  235. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利类型" size="small" clearable @change="changeFlWallet(scope.$index)">
  236. <el-option
  237. v-for="item in scope.row.rebateWallets"
  238. :key="item.customerWalletId"
  239. :label="item.customerWalletName"
  240. :value="item.customerWalletId">
  241. </el-option>
  242. </el-select>
  243. </template>
  244. </el-table-column>
  245. <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
  246. <template slot-scope="scope">
  247. {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
  248. </template>
  249. </el-table-column>
  250. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  251. <template slot-scope="scope">
  252. {{scope.row.qty * scope.row.discAmount}}
  253. </template>
  254. </el-table-column>
  255. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  256. <template slot-scope="scope">
  257. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable @change="changeXjWallet(scope.$index)">
  258. <el-option
  259. v-for="item in scope.row.wallets"
  260. :key="item.customerWalletId"
  261. :label="item.customerWalletName"
  262. :value="item.customerWalletId">
  263. </el-option>
  264. </el-select>
  265. </template>
  266. </el-table-column>
  267. <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  268. <template slot-scope="scope">
  269. {{((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100}}
  270. </template>
  271. </el-table-column>
  272. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  273. <template slot-scope="scope">
  274. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  275. </template>
  276. </el-table-column>
  277. <el-table-column align="center" label="直调数量" prop="directTransferQty" min-width="100"></el-table-column>
  278. <el-table-column align="center" label="已发货数量" prop="hasSendQty" min-width="100" show-overflow-tooltip></el-table-column>
  279. <el-table-column align="center" label="已退数量" prop="retiredQty" min-width="100" show-overflow-tooltip></el-table-column>
  280. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  281. <template slot-scope="scope">
  282. <el-input v-model="scope.row.remark" size="small"></el-input>
  283. </template>
  284. </el-table-column>
  285. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  286. <!-- <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip>
  287. <template slot-scope="scope">
  288. <div>{{ scope.row.status1 | status1Filter }}</div>
  289. </template>
  290. </el-table-column> -->
  291. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  292. <template slot-scope="scope">
  293. <div>{{ status2Filter(scope.row) }}</div>
  294. </template>
  295. </el-table-column>
  296. <!-- <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  297. <template slot-scope="scope">
  298. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" size="small" clearable disabled>
  299. <el-option
  300. v-for="item in salesmanList"
  301. :key="item.adminUserId"
  302. :label="item.nickName"
  303. :value="item.adminUserId">
  304. </el-option>
  305. </el-select>
  306. </template>
  307. </el-table-column> -->
  308. <el-table-column align="center" label="操作" width="100" fixed="right">
  309. <template slot-scope="scope">
  310. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  311. </template>
  312. </el-table-column>
  313. </el-table>
  314. </div>
  315. <div class="page-footer">
  316. <div class="footer">
  317. <el-button type="primary" @click="clickSubmitForm(1)" :loading="formLoading">保 存</el-button>
  318. <el-button type="primary" @click="clickSubmitForm(2)" :loading="formLoading">提交审核</el-button>
  319. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;" v-if=" !isDealer">
  320. <el-button slot="reference">关 闭</el-button>
  321. </el-popconfirm>
  322. </div>
  323. </div>
  324. <!-- 工程登录列表 -->
  325. <el-dialog title="工程登录列表" :visible.sync="isShowDialog" width="70%" :close-on-click-modal="false">
  326. <el-form ref="screenForm" :model="screenForm" label-width="0" size="small" label-position="left">
  327. <el-row :gutter="20">
  328. <el-col :xs="24" :sm="12" :lg="6">
  329. <el-form-item prop="loginNum">
  330. <el-input v-model="screenForm.loginNum" placeholder="工程登录编号"></el-input>
  331. </el-form-item>
  332. </el-col>
  333. <el-col :xs="24" :sm="12" :lg="6">
  334. <el-form-item prop="enginName">
  335. <el-input v-model="screenForm.enginName" placeholder="工程类别"></el-input>
  336. </el-form-item>
  337. </el-col>
  338. <el-col :xs="24" :sm="12" :lg="6">
  339. <el-form-item prop="company">
  340. <el-input v-model="screenForm.company" placeholder="使用单位"></el-input>
  341. </el-form-item>
  342. </el-col>
  343. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  344. <el-form-item label="">
  345. <el-button size="small" @click="resetScreenForm">清空</el-button>
  346. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  347. </el-form-item>
  348. </el-col>
  349. </el-row>
  350. </el-form>
  351. <div class="table" style="margin: 10px 0 20px;">
  352. <el-table
  353. v-loading="dialogTable_listLoading"
  354. :data="dialogTable_dataList"
  355. element-loading-text="Loading"
  356. tooltip-effect="dark"
  357. style="width: 100%"
  358. max-height="270">
  359. <el-table-column align="center" label="" width="100">
  360. <template slot-scope="scope">
  361. <el-button type="primary" size="small" @click="chooseItem(scope.row.recordNo, scope.row.userid)">选择</el-button>
  362. </template>
  363. </el-table-column>
  364. <el-table-column align="center" prop="checkTime" label="工程登录日期" show-overflow-tooltip></el-table-column>
  365. <el-table-column align="center" prop="recordNo" label="工程登录编号" show-overflow-tooltip></el-table-column>
  366. <el-table-column align="center" prop="projectName" label="项目类别" show-overflow-tooltip></el-table-column>
  367. <el-table-column align="center" prop="useUnit" label="使用单位" show-overflow-tooltip></el-table-column>
  368. <el-table-column align="center" prop="organizationName" label="经销商" show-overflow-tooltip></el-table-column>
  369. </el-table>
  370. </div>
  371. <div class="pagination clearfix">
  372. <div class="fr">
  373. <el-pagination
  374. @current-change="dialogTableCurrentChange"
  375. :current-page="dialogTable_currentPage"
  376. :page-size="dialogTable_pageSize"
  377. background
  378. layout="prev, pager, next"
  379. :total="dialogTable_listTotal">
  380. </el-pagination>
  381. </div>
  382. </div>
  383. <div slot="footer" class="dialog-footer">
  384. <el-button @click="isShowDialog = false">关 闭</el-button>
  385. </div>
  386. </el-dialog>
  387. <el-dialog title="添加产品" :visible.sync="isShowGoodsDialog" width="80%">
  388. <el-form ref="goodsScreenForm" :model="goodsScreenForm" size="small" label-position="left">
  389. <el-row :gutter="20">
  390. <el-col :xs="12" :sm="6" :lg="6">
  391. <el-form-item prop="proNum">
  392. <el-input v-model="goodsScreenForm.proNum" placeholder="请输入产品编码"></el-input>
  393. </el-form-item>
  394. </el-col>
  395. <el-col :xs="12" :sm="6" :lg="6">
  396. <el-form-item prop="proName">
  397. <el-input v-model="goodsScreenForm.proName" placeholder="请输入产品名称"></el-input>
  398. </el-form-item>
  399. </el-col>
  400. <el-col :xs="12" :sm="6" :lg="6">
  401. <el-form-item prop="proModel">
  402. <el-input v-model="goodsScreenForm.proModel" placeholder="请输入产品型号"></el-input>
  403. </el-form-item>
  404. </el-col>
  405. <el-col :xs="12" :sm="6" :lg="6">
  406. <el-form-item prop="price1" style="display: flex">
  407. <el-input v-model="goodsScreenForm.price1" placeholder="请输入价格" style="width: 46%"></el-input>
  408. <span> - </span>
  409. <el-input v-model="goodsScreenForm.price2" placeholder="请输入价格" style="width: 46%"></el-input>
  410. </el-form-item>
  411. </el-col>
  412. <el-col :xs="24" :sm="24" :lg="24" class="tr">
  413. <el-form-item label="">
  414. <el-button size="small" @click="resetGoodsScreenForm">清空</el-button>
  415. <el-button size="small" type="primary" @click="submitGoodsScreenForm">搜索</el-button>
  416. </el-form-item>
  417. </el-col>
  418. </el-row>
  419. </el-form>
  420. <div class="tables">
  421. <div class="table">
  422. <el-table :data="leftGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="leftSelectionChange">
  423. <el-table-column align="center" type="selection" width="55" :selectable='checkboxSelect'></el-table-column>
  424. <el-table-column align="center" label="销售类型" prop="saleName" min-width="100" show-overflow-tooltip></el-table-column>
  425. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  426. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  427. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  428. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  429. </el-table>
  430. <div class="pagination clearfix" style="margin-top: 10px">
  431. <div class="fr">
  432. <el-pagination
  433. @current-change="handleTableCurrentChange"
  434. :current-page="currentPage"
  435. :page-size="10"
  436. background
  437. layout="prev, pager, next"
  438. :total="listTotal">
  439. </el-pagination>
  440. </div>
  441. </div>
  442. </div>
  443. <div class="buttons">
  444. <el-button size="small" type="primary" @click="addAllGoods">全部添加</el-button>
  445. <el-button size="small" type="primary" @click="addGoods">添&emsp;加</el-button>
  446. <el-button size="small" type="danger" @click="deleteGoods">删&emsp;除</el-button>
  447. <el-button size="small" type="danger" @click="deleteAllGoods">全部删除</el-button>
  448. </div>
  449. <div class="table">
  450. <el-table :data="rightGoodsList" element-loading-text="Loading" border fit highlight-current-row stripe height="400" @selection-change="rightSelectionChange">
  451. <el-table-column align="center" type="selection" width="55"></el-table-column>
  452. <el-table-column align="center" label="产品编码" prop="number" min-width="100" show-overflow-tooltip></el-table-column>
  453. <el-table-column align="center" label="产品名称" prop="name" min-width="160" show-overflow-tooltip></el-table-column>
  454. <el-table-column align="center" label="产品型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
  455. <el-table-column align="center" label="产品价格" prop="batchPrice" min-width="80" show-overflow-tooltip></el-table-column>
  456. </el-table>
  457. </div>
  458. </div>
  459. <span slot="footer" class="dialog-footer">
  460. <el-button @click="closeDialog">取 消</el-button>
  461. <el-button type="primary" @click="submitAddGoods">确 定</el-button>
  462. </span>
  463. </el-dialog>
  464. </div>
  465. </template>
  466. <script>
  467. import { getOrderDetail, getHomeLoginList, getHomeLoginDetail, getWarehouseList, addHome, editHome, submitHome, checkStock, getRetailProductList } from "@/api/supply/engin";
  468. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  469. import { findElem } from '@/utils/util'
  470. let that
  471. export default {
  472. name: 'HomeForm',
  473. componentName: 'HomeForm',
  474. props: ['listItem'],
  475. filters: {
  476. status1Filter(val) {
  477. let STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue;
  478. let STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue;
  479. let STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue;
  480. let STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue;
  481. let STOCK_ORDER_ALL_NUM = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_ALL_NUM').dictValue;
  482. if (val === '' || val === null || val === undefined) return '未检查';
  483. else if (val <= 0) return '无货';
  484. else if (val > STOCK_ORDER_START && val <= STOCK_ORDER_END) return val;
  485. else if (val >= STOCK_ORDER_HAVE_START && val <= STOCK_ORDER_HAVE_END) return '有货';
  486. else if (val > STOCK_ORDER_ALL_NUM) return '充足';
  487. },
  488. },
  489. data() {
  490. return {
  491. editId: '',
  492. mainForm: {
  493. customerId: '',
  494. orderNum: '',
  495. orderDate: '',
  496. type: '',
  497. jxsNum: '',
  498. jxsName: '',
  499. loginNum: '',
  500. enginName: '',
  501. loginType: '',
  502. promiseStatus: '',
  503. factoryNum: '',
  504. company: '',
  505. saleType: '',
  506. contactMan: '',
  507. tel: '',
  508. phone: '',
  509. address: '',
  510. declareNo: '',
  511. greeRemark: '',
  512. greeReply: '',
  513. remark: '',
  514. createMan: '',
  515. createDate: '',
  516. fileNum: '',
  517. loginUserId: '',
  518. salesMan: '',
  519. projectRemark: '',
  520. projectType: '',
  521. examineRemark: '',
  522. refCount: '',
  523. regionWork: '',
  524. examineStatus: '',
  525. refBuyUnitName: '',
  526. refPromiseProvide: '',
  527. refOtherAnnexIdea: '',
  528. },
  529. mainFormRules: {
  530. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  531. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  532. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  533. loginNum: [{ required: true, message: '请输入工程登录编号', trigger: 'blur' }],
  534. // enginName: [{ required: true, message: '请输入项目类别', trigger: 'blur' }],
  535. // loginType: [{ required: true, message: '请输入行业类别', trigger: 'blur' }],
  536. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  537. saleType: [{ required: true, message: '请选择销售类型', trigger: 'change' }],
  538. // contactMan: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  539. // tel: [{ required: true, message: '请输入固定电话', trigger: 'blur' }],
  540. // phone: [{ required: true, message: '请输入移动电话', trigger: 'blur' }],
  541. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  542. },
  543. salesTypeList: [],
  544. // typeList: [],
  545. stockList: [],
  546. goodsList: [],
  547. isShowDialog: false, // 工程登录列表 - 弹窗
  548. screenForm: {
  549. loginNum: '',
  550. enginName: '',
  551. company: '',
  552. },
  553. dialogTable_dataList: null, // 工程登录列表 - 列表数据
  554. dialogTable_listLoading: true, // 工程登录列表 - 列表加载loading
  555. dialogTable_currentPage: 1, // 工程登录列表 - 当前页码
  556. dialogTable_pageSize: 10, // 工程登录列表 - 每页数量
  557. dialogTable_listTotal: 0, // 工程登录列表 - 列表总数
  558. warehouseList: [],
  559. warehouseValue: '',
  560. isShowGoodsDialog: false,
  561. goodsScreenForm: {
  562. proNum: '',
  563. proName: '',
  564. proModel: '',
  565. price1: '',
  566. price2: '',
  567. },
  568. currentPage: 1,
  569. listTotal: 0,
  570. leftGoodsList: [],
  571. rightGoodsList: [],
  572. leftSelection: [],
  573. rightSelection: [],
  574. formLoading: false,
  575. isFirst: false,
  576. salesmanList: [],
  577. oldSaleType: '',
  578. notInRefQueryGoodsList: ''
  579. }
  580. },
  581. computed: {
  582. isDealer() {
  583. return JSON.parse(localStorage.getItem("supply_user")).isCustomer
  584. },
  585. outSalesmanList() {
  586. let list = [];
  587. if(this.goodsList && this.goodsList.length) {
  588. this.goodsList.forEach(item => {
  589. if(item.serviceId) {
  590. let hasItem = findElem(list, 'adminUserId', item.serviceId);
  591. if(hasItem < 0) {
  592. let obj = this.salesmanList.find(o => o.adminUserId == item.serviceId);
  593. if(obj) {
  594. list.push(obj);
  595. }
  596. }
  597. }
  598. })
  599. if(this.isFirst) {
  600. this.isFirst = false;
  601. }else {
  602. this.mainForm.salesMan = this.goodsList[0].serviceId;
  603. }
  604. }
  605. return list
  606. }
  607. },
  608. watch: {
  609. goodsList: {
  610. handler(newValue, oldValue) {
  611. if(this.goodsList && this.goodsList.length) {
  612. if(this.isFirst) {
  613. this.isFirst = false;
  614. }else {
  615. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  616. }
  617. }else {
  618. this.mainForm.salesMan = '';
  619. }
  620. },
  621. immediate: true,
  622. deep: true
  623. },
  624. 'mainForm.saleType': function (newValue, oldValue) {
  625. this.oldSaleType = oldValue
  626. }
  627. },
  628. beforeCreate() {
  629. that = this;
  630. },
  631. async created() {
  632. await this.getSalesmanList();
  633. this.getDictList();
  634. this.getSalesTypeList();
  635. this.getWarehouseList();
  636. if(this.listItem) {
  637. this.isFirst = true;
  638. this.editId = this.listItem.parentId;
  639. this.getDetail();
  640. }else {
  641. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  642. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  643. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  644. this.mainForm.createDate = this.getDate();
  645. }
  646. },
  647. methods: {
  648. // 返回列表
  649. goBack() {
  650. this.$emit('backListFormDetail');
  651. },
  652. getDate() {
  653. var date = new Date();
  654. var seperator1 = "-";
  655. var year = date.getFullYear();
  656. var month = date.getMonth() + 1;
  657. var strDate = date.getDate();
  658. if (month >= 1 && month <= 9) {
  659. month = "0" + month;
  660. }
  661. if (strDate >= 0 && strDate <= 9) {
  662. strDate = "0" + strDate;
  663. }
  664. var currentdate = year + seperator1 + month + seperator1 + strDate;
  665. return currentdate;
  666. },
  667. // 获取产品大类列表
  668. getDictList() {
  669. // getDictList({sysDictEnum: 'PRODUCT_TYPE'}).then(res => {
  670. // this.typeList = res.data;
  671. // })
  672. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  673. this.stockList = res.data;
  674. })
  675. },
  676. // 获取销售类型列表
  677. getSalesTypeList() {
  678. getTypeList({
  679. pageNum: 1,
  680. pageSize: -1
  681. }).then((res) => {
  682. this.salesTypeList = res.data.records;
  683. })
  684. },
  685. // 获取仓库列表
  686. getWarehouseList() {
  687. getWarehouseList({
  688. pageNum: 1,
  689. pageSize: -1
  690. }).then((res) => {
  691. this.warehouseList = res.data.records;
  692. })
  693. },
  694. async getSalesmanList() {
  695. const res = await getSalesmanList({
  696. pageNum: 1,
  697. pageSize: -1,
  698. isCustomer: 0,
  699. status: true,
  700. });
  701. this.salesmanList = res.data.records;
  702. },
  703. // 工程登录列表 - 获取列表
  704. getHomeLoginList() {
  705. getHomeLoginList({
  706. pageNum: this.dialogTable_currentPage,
  707. pageSize: this.dialogTable_pageSize,
  708. recordNo: this.screenForm.loginNum,
  709. projectName: this.screenForm.enginName,
  710. useUnit: this.screenForm.company,
  711. examineStatus: 'OK'
  712. }).then(res => {
  713. this.dialogTable_dataList = res.data.records;
  714. this.dialogTable_listTotal = res.data.total;
  715. this.dialogTable_listLoading = false;
  716. })
  717. },
  718. // 工程登录列表 - 打开弹窗
  719. openShareDetail() {
  720. if(!this.mainForm.saleType) {
  721. return this.$errorMsg('请先选择销售类型');
  722. }
  723. this.isShowDialog = true;
  724. this.dialogTable_currentPage = 1;
  725. this.screenForm.loginNum = this.mainForm.loginNum;
  726. this.getHomeLoginList();
  727. },
  728. // 工程登录列表 - 更改列表当前页
  729. dialogTableCurrentChange(val) {
  730. this.dialogTable_currentPage = val;
  731. this.getHomeLoginList();
  732. },
  733. // 提交筛选表单
  734. submitScreenForm() {
  735. this.dialogTable_currentPage = 1;
  736. this.getHomeLoginList();
  737. },
  738. // 重置筛选表单
  739. resetScreenForm() {
  740. this.$refs.screenForm.resetFields();
  741. this.dialogTable_currentPage = 1;
  742. this.getHomeLoginList();
  743. },
  744. // 选择工程登录
  745. async chooseItem(id, uid, isChangeSaleType = false) {
  746. let isCustomer = JSON.parse(localStorage.getItem("supply_user")).isCustomer
  747. let customerId = JSON.parse(localStorage.getItem("supply_user")).customerId
  748. if (!isCustomer) {
  749. customerId = this.mainForm.customerId
  750. }
  751. getHomeLoginDetail({
  752. recordNo: id,
  753. saleTypeId: this.mainForm.saleType,
  754. userId: uid,
  755. enginOrderId: this.mainForm.orderNum,
  756. customerId: customerId
  757. }).then(async res => {
  758. // 复制当前明细数据
  759. let copyGoodsList = JSON.parse(JSON.stringify(this.goodsList));
  760. console.log('未刷新前', copyGoodsList)
  761. if (!isChangeSaleType) {
  762. this.setMainAndItem(res.data)
  763. } else {
  764. // 找出不属于引用单上的产品
  765. if (copyGoodsList && copyGoodsList.length > 0) {
  766. let notInRefGoodsList = []
  767. for (let i = 0; i < copyGoodsList.length; i++) {
  768. let goods = copyGoodsList[i]
  769. let index = res.data.items.findIndex(v => v.materialOldNumber === goods.materialOldNumber)
  770. if (index < 0) {
  771. notInRefGoodsList.push(goods)
  772. }
  773. }
  774. if (notInRefGoodsList && notInRefGoodsList.length > 0) {
  775. let oldNumbers = []
  776. notInRefGoodsList.forEach(v => oldNumbers.push(v.materialOldNumber))
  777. console.log('请求前可选机型接口', notInRefGoodsList, oldNumbers)
  778. // 请求可选机型接口
  779. await this.querySaleTypeGoods(oldNumbers)
  780. console.log('返回新加明细', this.notInRefQueryGoodsList)
  781. if (!this.notInRefQueryGoodsList) {
  782. console.log('结束执行下去')
  783. return
  784. }
  785. this.addRefItems(res.data.items, notInRefGoodsList)
  786. }
  787. // 数量和价格不变更
  788. console.log('执行下去,数量和价格不变更')
  789. }
  790. console.log('替换前', res.data.items)
  791. res.data.items = this.replaceHistoryItems(res.data.items, copyGoodsList)
  792. console.log('替换后', res.data.items)
  793. this.setMainAndItem(res.data)
  794. }
  795. }).catch(() => {
  796. this.mainForm.saleType = this.oldSaleType
  797. })
  798. },
  799. // 选择销售类型
  800. changeSaleType() {
  801. if(this.mainForm.loginNum) {
  802. this.chooseItem(this.mainForm.loginNum, this.mainForm.loginUserId, true);
  803. }
  804. },
  805. // 删除产品
  806. deleteItem(index) {
  807. this.goodsList.splice(index, 1);
  808. },
  809. // 修改返利钱包
  810. changeFlWallet(index) {
  811. if(this.goodsList[index].customerWalletId2) {
  812. let obj = this.goodsList[index].rebateWallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2);
  813. this.goodsList[index].rebateRate = obj.rebateRate;
  814. this.goodsList[index].customerWalletName2 = obj.customerWalletName;
  815. }else {
  816. this.goodsList[index].rebateRate = '';
  817. this.goodsList[index].customerWalletName2 = '';
  818. }
  819. },
  820. // 修改现金钱包
  821. changeXjWallet(index) {
  822. if(this.goodsList[index].customerWalletId) {
  823. let obj = this.goodsList[index].wallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId);
  824. this.goodsList[index].customerWalletName = obj.customerWalletName;
  825. this.goodsList[index].serviceId = obj.serviceId;
  826. this.goodsList[index].serviceName = obj.serviceName;
  827. }else {
  828. this.goodsList[index].customerWalletName = '';
  829. this.goodsList[index].serviceId = '';
  830. this.goodsList[index].serviceName = '';
  831. }
  832. },
  833. // 获取详情
  834. getDetail() {
  835. getOrderDetail({id: this.editId}).then(res => {
  836. let data = res.data;
  837. this.mainForm.customerId = data.customerId
  838. this.mainForm.orderNum = data.enginOrderId;
  839. this.mainForm.orderDate = data.orderDate;
  840. this.mainForm.type = data.mainId;
  841. this.mainForm.jxsNum = data.customerNumber;
  842. this.mainForm.jxsName = data.customerName;
  843. this.mainForm.loginNum = data.refEnginRecordNo;
  844. this.mainForm.enginName = data.refProjectCategory;
  845. this.mainForm.loginType = data.refTradeCategory;
  846. this.mainForm.promiseStatus = data.refPromiseStatus;
  847. this.mainForm.factoryNum = data.refFactoryNo;
  848. this.mainForm.company = data.refUseUnit;
  849. this.mainForm.saleType = data.saleTypeId;
  850. this.mainForm.contactMan = data.refLinkman;
  851. this.mainForm.tel = data.refTel;
  852. this.mainForm.phone = data.refPhone;
  853. this.mainForm.address = data.refInstallAddress;
  854. this.mainForm.declareNo = data.refDeclareNo;
  855. this.mainForm.refCount = data.refCount;
  856. this.mainForm.greeRemark = data.geLiInerNote;
  857. this.mainForm.greeReply = data.note1;
  858. this.mainForm.remark = data.remark;
  859. this.mainForm.createMan = data.createName;
  860. this.mainForm.createDate = data.createTime;
  861. this.mainForm.fileNum = data.fileNo;
  862. this.mainForm.salesMan = data.serviceId;
  863. this.mainForm.projectRemark = data.refProjectNote;
  864. this.mainForm.projectType = data.refProjectType;
  865. this.mainForm.examineRemark = data.examineNote;
  866. this.mainForm.loginUserId = data.loginUserId;
  867. this.mainForm.regionWork = data.refRegionWork;
  868. this.mainForm.examineStatus = data.examineStatus;
  869. this.mainForm.refBuyUnitName = data.refBuyUnitName;
  870. this.mainForm.refPromiseProvide = data.refPromiseProvide;
  871. data.items.forEach(item => {
  872. item.status1 = '';
  873. item.status2 = '';
  874. item.rebateWallets = item.customerWalletList.filter(item => {
  875. return item.type === 'REBATE';
  876. });
  877. item.wallets = item.customerWalletList.filter(item => {
  878. return item.type === 'COMMONLY';
  879. });
  880. })
  881. this.goodsList = data.items;
  882. })
  883. },
  884. // 获取商品列表
  885. getGoodsList() {
  886. getRetailProductList({
  887. pageNum: this.currentPage,
  888. pageSize: 10,
  889. saleId: this.mainForm.saleType,
  890. billType: 'HOME',
  891. materialCode: this.goodsScreenForm.proNum,
  892. materialName: this.goodsScreenForm.proName,
  893. specification: this.goodsScreenForm.proModel,
  894. price1: this.goodsScreenForm.price1,
  895. price2: this.goodsScreenForm.price2,
  896. customerId:this.listItem ?this.listItem.customerId :'' ,
  897. }).then(res => {
  898. let oldGoodsList = this.goodsList;
  899. let newGoodsList = res.data.records;
  900. for(let i = 0; i < oldGoodsList.length; i++) {
  901. let oldItem = oldGoodsList[i]
  902. for(let j = 0; j < newGoodsList.length; j++) {
  903. let newItem = newGoodsList[j]
  904. if(newItem.id === oldItem.id){
  905. newGoodsList[j].selected = true;
  906. break;
  907. }
  908. }
  909. }
  910. res.data.records.forEach(item => {
  911. item.materialName = item.name;
  912. item.materialCode = item.number;
  913. item.saleTypeName = item.saleName;
  914. item.unit = item.baseUnit;
  915. item.enginNum = 0;
  916. item.qty = 0;
  917. item.price = item.batchPrice;
  918. item.tax = item.taxRate;
  919. item.isDirectTransfer = false;
  920. item.directTransferQty = '';
  921. item.status1 = '';
  922. item.status2 = '';
  923. item.rebateAmount = '';
  924. item.rebateRate = '';
  925. item.productPriceId = item.id;
  926. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  927. });
  928. this.leftGoodsList = res.data.records;
  929. this.listTotal = res.data.total;
  930. })
  931. },
  932. // 查询重复值并禁选
  933. checkboxSelect(row, rowIndex) {
  934. if (row.selected) {
  935. return false // 禁用
  936. }else{
  937. return true // 不禁用
  938. }
  939. },
  940. // 点击 选择商品
  941. openDialog() {
  942. if(!this.mainForm.saleType) {
  943. return this.$errorMsg('请先选择销售类型');
  944. }
  945. this.isShowGoodsDialog = true;
  946. this.getGoodsList();
  947. },
  948. // 提交筛选表单
  949. submitGoodsScreenForm() {
  950. this.currentPage = 1;
  951. this.getGoodsList();
  952. },
  953. // 重置筛选表单
  954. resetGoodsScreenForm() {
  955. this.$refs.goodsScreenForm.resetFields();
  956. this.currentPage = 1;
  957. this.getGoodsList();
  958. },
  959. // 更改列表当前页
  960. handleTableCurrentChange(val) {
  961. this.currentPage = val;
  962. this.getGoodsList();
  963. },
  964. // 关闭 弹窗
  965. closeDialog() {
  966. this.isShowGoodsDialog = false;
  967. },
  968. // 左侧列表选择
  969. leftSelectionChange(val) {
  970. this.leftSelection = val;
  971. },
  972. // 右侧列表选择
  973. rightSelectionChange(val) {
  974. this.rightSelection = val;
  975. },
  976. // 数组去重
  977. delRepeat(arr1, arr2) {
  978. let allArr = arr1.concat(arr2); // 两个数组对象合并
  979. let newArr = []; // 存放去重后数据的新数组
  980. for(let i=0; i<allArr.length; i++){ // 循环allArr数组对象的内容
  981. let flag = true; // 建立标记,判断数据是否重复,true为不重复
  982. for(let j=0; j<newArr.length; j++){ // 循环新数组的内容
  983. if(allArr[i].id == newArr[j].id){ // 让allArr数组对象的内容与新数组的内容作比较,相同的话,改变标记为false
  984. flag = false;
  985. }
  986. }
  987. if(flag){ // 判断是否重复
  988. newArr.push(allArr[i]); // 不重复的放入新数组。 新数组的内容会继续进行上边的循环。
  989. }
  990. }
  991. return newArr;
  992. },
  993. // 全部添加
  994. addAllGoods() {
  995. this.rightGoodsList = this.delRepeat(this.leftGoodsList, this.rightGoodsList);
  996. },
  997. // 添加
  998. addGoods() {
  999. this.rightGoodsList = this.delRepeat(this.leftSelection, this.rightGoodsList);
  1000. },
  1001. // 删除
  1002. deleteGoods() {
  1003. let rightGoodsList = this.rightGoodsList;
  1004. let rightSelection = this.rightSelection;
  1005. for(let i = 0; i < rightGoodsList.length; i++) {
  1006. for(let j = 0; j < rightSelection.length; j++) {
  1007. if(rightSelection[j].materialId == rightGoodsList[i].materialId){
  1008. this.rightGoodsList.splice(i, 1);
  1009. }
  1010. }
  1011. }
  1012. },
  1013. // 全部删除
  1014. deleteAllGoods() {
  1015. this.rightGoodsList = [];
  1016. },
  1017. // 确定 添加产品
  1018. submitAddGoods() {
  1019. // this.goodsList = this.delRepeat(this.rightGoodsList, this.goodsList);
  1020. this.goodsList = this.goodsList.concat(this.rightGoodsList);
  1021. this.isShowGoodsDialog = false;
  1022. this.leftGoodsList = [];
  1023. this.rightGoodsList = [];
  1024. },
  1025. // 检查库存
  1026. checkStock() {
  1027. if(!this.warehouseValue) {
  1028. return this.$errorMsg('请选择仓库');
  1029. }
  1030. if(!this.goodsList) {
  1031. return this.$errorMsg('请添加货品');
  1032. }
  1033. let ids = [];
  1034. this.goodsList.forEach(item => {
  1035. ids.push(item.materialId);
  1036. })
  1037. checkStock({
  1038. correspondId: this.warehouseValue,
  1039. materialId: ids.join(',')
  1040. }).then(res => {
  1041. if(res.data) {
  1042. this.goodsList.forEach((item, index) => {
  1043. item.status1 = res.data[index].allStockNum;
  1044. item.status2 = res.data[index].stockNum;
  1045. })
  1046. }
  1047. })
  1048. },
  1049. status2Filter(item) {
  1050. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查';
  1051. else if (item.status2 <= 0) return '无货';
  1052. if ( item.status2 <= 0 ) {
  1053. return '无货'
  1054. }else if(item.status2 >= 1 && item.status2 <= 30){
  1055. return item.status2
  1056. }else if(item.status2 >=31 && item.status2 <= 1000 ){
  1057. return '有货'
  1058. }else{
  1059. return '充足'
  1060. }
  1061. },
  1062. // 保存 / 提交审核
  1063. clickSubmitForm(type) {
  1064. this.$refs.mainForm.validate((valid) => {
  1065. if (valid) {
  1066. for(let i=0; i<this.goodsList.length; i++) {
  1067. if(!this.goodsList[i].customerWalletId) {
  1068. this.$errorMsg('请选择现金钱包');
  1069. return;
  1070. }
  1071. if(type !=2){
  1072. if(!this.goodsList[i].qty) {
  1073. this.$errorMsg('金额不能为0');
  1074. return;
  1075. }
  1076. }
  1077. }
  1078. let goodsList = JSON.parse(JSON.stringify(this.goodsList));
  1079. goodsList.forEach(item => {
  1080. delete item.rebateWallets;
  1081. delete item.wallets;
  1082. })
  1083. let saleTypeItem = this.salesTypeList.find(o => o.id == this.mainForm.saleType);
  1084. let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
  1085. let params = {
  1086. enginOrderId: this.mainForm.orderNum,
  1087. loginUserId: this.mainForm.loginUserId,
  1088. refEnginRecordNo: this.mainForm.loginNum || '',
  1089. refProjectCategory: this.mainForm.enginName || '',
  1090. refTradeCategory: this.mainForm.loginType || '',
  1091. refPromiseStatus: this.mainForm.promiseStatus || '',
  1092. refFactoryNo: this.mainForm.factoryNum || '',
  1093. refUseUnit: this.mainForm.company || '',
  1094. refLinkman: this.mainForm.contactMan || '',
  1095. refTel: this.mainForm.tel || '',
  1096. refPhone: this.mainForm.phone || '',
  1097. refInstallAddress: this.mainForm.address || '',
  1098. refDeclareNo: this.mainForm.declareNo || '',
  1099. refCount: this.mainForm.refCount || '',
  1100. saleTypeId: this.mainForm.saleType,
  1101. saleTypeCode: saleTypeItem.saleCode,
  1102. saleTypeName: saleTypeItem.saleName,
  1103. geLiInerNote: this.mainForm.greeRemark || '',
  1104. geLiNote: this.mainForm.greeReply || '',
  1105. remark: this.mainForm.remark || '',
  1106. fileNo: this.mainForm.fileNum || '',
  1107. serviceId: this.mainForm.salesMan,
  1108. serviceName: saleManItem ? saleManItem.nickName : goodsList[0].serviceName,
  1109. refProjectNote: this.mainForm.projectRemark,
  1110. refProjectType: this.mainForm.projectType,
  1111. refRegionWork: this.mainForm.regionWork,
  1112. refBuyUnitName: this.mainForm.refBuyUnitName,
  1113. refPromiseProvide: this.mainForm.refPromiseProvide,
  1114. refOtherAnnexIdea: this.mainForm.refOtherAnnexIdea,
  1115. items: goodsList,
  1116. }
  1117. this.formLoading = true;
  1118. if(type === 1) {
  1119. if(this.listItem) {
  1120. editHome(params).then(res => {
  1121. this.$successMsg('编辑成功');
  1122. this.goBack();
  1123. this.$parent.getList();
  1124. }).finally(res => {
  1125. this.formLoading = false;
  1126. })
  1127. }else {
  1128. addHome(params).then(res => {
  1129. this.$successMsg('新增成功');
  1130. this.goBack();
  1131. this.$parent.getList();
  1132. }).finally(res => {
  1133. this.formLoading = false;
  1134. })
  1135. }
  1136. }else if(type === 2) {
  1137. submitHome(params).then(res => {
  1138. this.$successMsg('提交审核成功');
  1139. this.goBack();
  1140. this.$parent.getList();
  1141. }).finally(res => {
  1142. this.formLoading = false;
  1143. })
  1144. }
  1145. }
  1146. })
  1147. },
  1148. setMainAndItem(data) {
  1149. this.isShowDialog = false;
  1150. this.mainForm.type = data.productCategory;
  1151. this.mainForm.loginUserId = data.userid;
  1152. // this.mainForm.saleType = '';
  1153. this.mainForm.loginNum = data.recordNo;
  1154. this.mainForm.enginName = data.projectName;
  1155. this.mainForm.loginType = data.tradeCategory;
  1156. this.mainForm.factoryNum = data.factoryNo;
  1157. this.mainForm.promiseStatus = data.promiseStatus;
  1158. this.mainForm.company = data.useUnit;
  1159. this.mainForm.contactMan = data.buyUnitCallMen;
  1160. this.mainForm.tel = data.buyUnitTel;
  1161. this.mainForm.phone = data.buyUnitPhone;
  1162. this.mainForm.address = data.installAddress;
  1163. this.mainForm.declareNo = data.declareNo;
  1164. this.mainForm.projectRemark = data.buChonShuoMing;
  1165. this.mainForm.projectType = data.govBuyType;
  1166. this.mainForm.refCount = data.refCount;
  1167. this.mainForm.regionWork = data.regionWork;
  1168. this.mainForm.refBuyUnitName = data.buyUnitName;
  1169. this.mainForm.refPromiseProvide = data.promiseProvide === 1 ? '已保证':'未保证';
  1170. this.mainForm.refOtherAnnexIdea = data.otherAnnexIdea;
  1171. let saleTypeItem = this.salesTypeList.find(o => o.id === this.mainForm.saleType);
  1172. this.goodsList = data.items.map(item => {
  1173. return {
  1174. useRefCount: item.useRefCount,
  1175. saleTypeId: saleTypeItem.id,
  1176. saleTypeCode: saleTypeItem.saleCode,
  1177. saleTypeName: saleTypeItem.saleName,
  1178. materialId: item.materialId,
  1179. materialNumber: item.materialNumber,
  1180. materialOldNumber: item.materialOldNumber,
  1181. materialName: item.materialName,
  1182. specification: item.machine,
  1183. enginNum: item.num,
  1184. enginPrice: item.price,
  1185. enginTotality: item.totality,
  1186. historyHasDeliverQty: item.hasDeliverQty,
  1187. unit: item.unit,
  1188. price: item.price,
  1189. qty: item.num,
  1190. customerWalletId2: '',
  1191. rebateRate: '',
  1192. discAmount: '',
  1193. customerWalletId: '',
  1194. isDirectTransfer: false,
  1195. directTransferQty: '',
  1196. hasSendQty: '',
  1197. remark: item.discri,
  1198. tax: '',
  1199. status1: '',
  1200. status2: '',
  1201. rebateWallets: item.customerWalletList.filter(item => {
  1202. return item.type === 'REBATE';
  1203. }),
  1204. wallets: item.customerWalletList.filter(item => {
  1205. return item.type === 'COMMONLY';
  1206. }),
  1207. }
  1208. })
  1209. this.goodsList.forEach(item => {
  1210. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  1211. item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
  1212. item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
  1213. })
  1214. },
  1215. async querySaleTypeGoods(oldNumbers) {
  1216. await getRetailProductList({
  1217. pageNum: 1,
  1218. pageSize: -1,
  1219. saleId: this.mainForm.saleType,
  1220. billType: 'HOME',
  1221. oldNumbers: oldNumbers.join(','),
  1222. customerId: this.mainForm.customerId
  1223. }).then(res => {
  1224. console.log('请求后可选机型接口', res.data.records)
  1225. if (!res.data.records || res.data.records.length === 0) {
  1226. this.mainForm.saleType = this.oldSaleType
  1227. console.log(1)
  1228. this.$errorMsg(oldNumbers.join(',') + " 产品无此销售类型")
  1229. this.notInRefQueryGoodsList = ''
  1230. return
  1231. }
  1232. if (res.data.records.length < oldNumbers.length) {
  1233. let notInOldNumbers = []
  1234. for (let i = 0; i < oldNumbers.length; i++) {
  1235. let oldNumber = oldNumbers[i]
  1236. let index = res.data.records.findIndex(v => v.materialOldNumber === oldNumber)
  1237. if (index < 0) {
  1238. notInOldNumbers.push(oldNumber)
  1239. }
  1240. }
  1241. this.mainForm.saleType = this.oldSaleType
  1242. console.log(2)
  1243. this.$errorMsg(notInOldNumbers.join(',') + " 产品无此销售类型")
  1244. this.notInRefQueryGoodsList = ''
  1245. return
  1246. }
  1247. this.notInRefQueryGoodsList = res.data.records
  1248. })
  1249. },
  1250. replaceHistoryItems(items, copyGoodsList) {
  1251. if (items && copyGoodsList) {
  1252. for (let i = 0; i < items.length; i++) {
  1253. let index = copyGoodsList.findIndex(v => v.materialOldNumber === items[i].materialOldNumber)
  1254. if (index >= 0) {
  1255. items[i].price = copyGoodsList[index].price
  1256. items[i].num = copyGoodsList[index].qty
  1257. items[i].discri = copyGoodsList[index].remark
  1258. }
  1259. }
  1260. }
  1261. return items
  1262. },
  1263. addRefItems(items, notInRefGoodsList) {
  1264. if (notInRefGoodsList && this.notInRefQueryGoodsList) {
  1265. for (let i = 0; i < notInRefGoodsList.length; i++) {
  1266. let index = this.notInRefQueryGoodsList.findIndex(v => v.materialOldNumber === notInRefGoodsList[i].materialOldNumber)
  1267. if (index >= 0) {
  1268. this.notInRefQueryGoodsList[index].batchPrice = notInRefGoodsList[i].price
  1269. this.notInRefQueryGoodsList[index].qty = notInRefGoodsList[i].qty
  1270. this.notInRefQueryGoodsList[index].remark = notInRefGoodsList[i].remark
  1271. }
  1272. }
  1273. console.log('非引用单产品', this.notInRefQueryGoodsList)
  1274. for (let i = 0; i < this.notInRefQueryGoodsList.length; i++) {
  1275. let goods = this.notInRefQueryGoodsList[i]
  1276. let customerWalletList = [].concat(goods.rebateWallets).concat(goods.wallets)
  1277. items.push({
  1278. saleTypeId: goods.saleTypeId,
  1279. saleTypeCode: goods.saleTypeCode,
  1280. saleTypeName: goods.saleTypeName,
  1281. materialId: goods.materialId,
  1282. materialNumber: goods.materialNumber,
  1283. materialOldNumber: goods.materialOldNumber,
  1284. materialName: goods.materialName,
  1285. machine: goods.specification,
  1286. num: goods.qty,
  1287. batchPrice: goods.batchPrice,
  1288. discri: goods.remark,
  1289. customerWalletList: customerWalletList
  1290. })
  1291. }
  1292. }
  1293. }
  1294. }
  1295. }
  1296. </script>
  1297. <style scoped lang="scss">
  1298. .detail-container {
  1299. width: 100%;
  1300. height: 100%;
  1301. }
  1302. .main-title {
  1303. display: flex;
  1304. justify-content: space-between;
  1305. align-items: center;
  1306. margin-top: 20px;
  1307. height: 60px;
  1308. border-bottom: 1px solid #DCDFE6;
  1309. margin-bottom: 20px;
  1310. .title {
  1311. font-size: 16px;
  1312. font-weight: 600;
  1313. padding-left: 10px;
  1314. }
  1315. }
  1316. .tables {
  1317. display: flex;
  1318. margin-top: 10px;
  1319. .table {
  1320. width: 45%;
  1321. }
  1322. .buttons {
  1323. display: flex;
  1324. flex-direction: column;
  1325. justify-content: center;
  1326. align-items: center;
  1327. padding: 0 10px;
  1328. button {
  1329. margin: 0;
  1330. margin-top: 10px;
  1331. }
  1332. }
  1333. }
  1334. ::v-deep input::-webkit-outer-spin-button,
  1335. ::v-deep input::-webkit-inner-spin-button {
  1336. -webkit-appearance: none;
  1337. }
  1338. ::v-deep input[type='number'] {
  1339. -moz-appearance: textfield;
  1340. }
  1341. </style>