home_form.vue 62 KB

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