commerce_form.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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="110px" 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="salesMan">
  28. <el-select v-model="mainForm.salesMan" disabled placeholder="选择业务员" size="small" filterable clearable style="width: 100%">
  29. <el-option
  30. v-for="item in salesmanList"
  31. :key="item.adminUserId"
  32. :label="item.nickName"
  33. :value="item.adminUserId">
  34. </el-option>
  35. </el-select>
  36. </el-form-item>
  37. </el-col>
  38. <!-- <el-col :xs="24" :sm="12" :lg="8">
  39. <el-form-item label="产品大类" prop="type">
  40. <el-select v-model="mainForm.type" placeholder="选择产品大类" style="width: 100%" disabled>
  41. <el-option v-for="item in typeList" :key="item.dictCode" :label="item.dictValue" :value="item.dictCode"></el-option>
  42. </el-select>
  43. </el-form-item>
  44. </el-col> -->
  45. </el-row>
  46. <el-row :gutter="20">
  47. <el-col :xs="24" :sm="12" :lg="8">
  48. <el-form-item label="经销商编码" prop="jxsNum">
  49. <el-input v-model="mainForm.jxsNum" placeholder="请输入经销商编码" disabled></el-input>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :xs="24" :sm="12" :lg="16">
  53. <el-form-item label="经销商名称" prop="jxsName">
  54. <el-input v-model="mainForm.jxsName" placeholder="请输入经销商名称" disabled></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :xs="24" :sm="12" :lg="8">
  58. <el-form-item label="工程信息单号" prop="enginOrderNum">
  59. <div style="display: flex;">
  60. <el-input v-model="mainForm.enginOrderNum" placeholder="请引用工程登录" disabled></el-input>
  61. <el-button style="margin-left: 10px;" @click="openShareDetail">引用</el-button>
  62. </div>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :xs="24" :sm="12" :lg="8">
  66. <el-form-item label="项目类别" prop="enginName">
  67. <el-input v-model="mainForm.enginName" placeholder="请输入项目类别" disabled></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :xs="24" :sm="12" :lg="8">
  71. <el-form-item label="行业类别" prop="loginType">
  72. <el-input v-model="mainForm.loginType" placeholder="请输入行业类别" disabled></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :xs="24" :sm="12" :lg="8">
  76. <el-form-item label="跨区厂编号" prop="factoryNum">
  77. <el-input v-model="mainForm.factoryNum" placeholder="请输入跨区厂编号" :disabled="isDealer"></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :xs="24" :sm="12" :lg="8">
  81. <el-form-item label="使用单位" prop="company">
  82. <el-input v-model="mainForm.company" placeholder="请输入使用单位" disabled></el-input>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :xs="24" :sm="12" :lg="8">
  86. <el-form-item label="工程编号" prop="enginNum">
  87. <el-input disabled v-model="mainForm.enginNum" placeholder="请输入工程编号"></el-input>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :xs="24" :sm="12" :lg="8">
  91. <el-form-item label="联系人" prop="contactMan">
  92. <el-input v-model="mainForm.contactMan" placeholder="请输入联系人" disabled></el-input>
  93. </el-form-item>
  94. </el-col>
  95. <el-col :xs="24" :sm="12" :lg="8">
  96. <el-form-item label="固定电话" prop="tel">
  97. <el-input v-model="mainForm.tel" placeholder="请输入固定电话" disabled></el-input>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :xs="24" :sm="12" :lg="8">
  101. <el-form-item label="移动电话" prop="phone">
  102. <el-input v-model="mainForm.phone" placeholder="请输入移动电话" disabled></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :xs="24" :sm="24" :lg="24">
  106. <el-form-item label="安装地址" prop="address">
  107. <el-input v-model="mainForm.address" placeholder="请输入安装地址" disabled></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :xs="24" :sm="24" :lg="16" v-if="!isDealer">
  111. <el-form-item label="格力内部备注" prop="greeRemark">
  112. <el-input v-model="mainForm.greeRemark" placeholder="请输入格力内部备注"></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :xs="24" :sm="12" :lg="8" v-if="!isDealer">
  116. <el-form-item label="权限分类" prop="power">
  117. <el-select v-model="mainForm.power" placeholder="选择权限分类" size="small" clearable style="width: 100%">
  118. <el-option
  119. v-for="item in powerList"
  120. :key="item.dictCode" :label="item.dictValue" :value="item.dictCode">
  121. </el-option>
  122. </el-select>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :xs="24" :sm="24" :lg="24">
  126. <el-form-item label="格力回复" prop="greeReply">
  127. <el-input v-model="mainForm.greeReply" placeholder="请输入格力回复"></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :xs="24" :sm="24" :lg="24" >
  131. <el-form-item label="备注" prop="remark">
  132. <el-input v-model="mainForm.remark" placeholder="请输入备注"></el-input>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :xs="24" :sm="12" :lg="8">
  136. <el-form-item label="制单人" prop="createMan">
  137. <el-input v-model="mainForm.createMan" placeholder="请输入制单人" disabled></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px;">
  141. <el-form-item label="制单日期" prop="createDate">
  142. <el-date-picker
  143. v-model="mainForm.createDate"
  144. disabled
  145. type="date"
  146. value-format="yyyy-MM-dd"
  147. style="width: 100%;"
  148. placeholder="选择日期">
  149. </el-date-picker>
  150. </el-form-item>
  151. </el-col>
  152. <el-col :xs="24" :sm="12" :lg="8">
  153. <el-form-item label="文件编号" prop="fileNum">
  154. <el-input v-model="mainForm.fileNum" placeholder="请输入文件编号"></el-input>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :xs="24" :sm="24" :lg="24" v-if="mainForm.examineRemark">
  158. <el-form-item label="审批说明" prop="examineRemark">
  159. <el-input v-model="mainForm.examineRemark" placeholder="请输入审批说明" disabled></el-input>
  160. </el-form-item>
  161. </el-col>
  162. </el-row>
  163. </el-form>
  164. <div class="main-title">
  165. <div class="title">货品信息</div>
  166. <div>
  167. <el-select v-model="warehouseValue" placeholder="请选择发货仓库" size="small" style="margin-right: 10px">
  168. <el-option :label="item.name" :value="item.id" v-for="(item, index) in warehouseList" :key="index"></el-option>
  169. </el-select>
  170. <el-button type="primary" size="small" icon="el-icon-search" @click="checkStock">检查库存</el-button>
  171. </div>
  172. </div>
  173. <div class="table" style="margin-top: 20px">
  174. <el-table :data="goodsList" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400" @selection-change="handleSelectionChange">
  175. <el-table-column align="center" type="selection" width="55"></el-table-column>
  176. <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
  177. <el-table-column align="center" label="引用记录" prop="useRefCount" min-width="160" show-overflow-tooltip></el-table-column>
  178. <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="120" show-overflow-tooltip></el-table-column>
  179. <el-table-column align="center" label="物料编码" prop="materialNumber" min-width="120" show-overflow-tooltip></el-table-column>
  180. <el-table-column align="center" label="产品编码" prop="materialOldNumber" min-width="120" show-overflow-tooltip></el-table-column>
  181. <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
  182. <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip>
  183. <template slot-scope="scope">
  184. <el-input v-model="scope.row.specification" size="small" v-if="listItem"></el-input>
  185. <div v-else>{{scope.row.specification}}</div>
  186. </template>
  187. </el-table-column>
  188. <el-table-column align="center" label="单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>
  189. <el-table-column align="center" label="单价" prop="price" min-width="100" show-overflow-tooltip>
  190. <template slot-scope="scope">
  191. <el-input v-model="scope.row.price" size="small" type="number" v-if="!isDealer"></el-input>
  192. <div v-else>{{scope.row.price}}</div>
  193. </template>
  194. </el-table-column>
  195. <el-table-column align="center" label="工程信息数量" prop="enginNum" min-width="120" show-overflow-tooltip></el-table-column>
  196. <el-table-column align="center" label="数量" prop="qty" min-width="100" show-overflow-tooltip>
  197. <template slot-scope="scope">
  198. <el-input v-model="scope.row.qty" size="small"></el-input>
  199. </template>
  200. </el-table-column>
  201. <el-table-column align="center" label="订单金额" min-width="100" show-overflow-tooltip>
  202. <template slot-scope="scope">
  203. {{scope.row.price * scope.row.qty}}
  204. </template>
  205. </el-table-column>
  206. <el-table-column align="center" label="返利钱包" prop="customerWalletId2" min-width="160" show-overflow-tooltip>
  207. <template slot-scope="scope">
  208. <el-select v-model="scope.row.customerWalletId2" placeholder="选择返利类型" size="small" clearable @change="changeFlWallet(scope.$index)">
  209. <el-option
  210. v-for="item in scope.row.rebateWallets"
  211. :key="item.customerWalletId"
  212. :label="item.customerWalletName"
  213. :value="item.customerWalletId">
  214. </el-option>
  215. </el-select>
  216. </template>
  217. </el-table-column>
  218. <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
  219. <template slot-scope="scope">
  220. {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
  221. </template>
  222. </el-table-column>
  223. <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
  224. <template slot-scope="scope">
  225. {{scope.row.qty * scope.row.discAmount}}
  226. </template>
  227. </el-table-column>
  228. <el-table-column align="center" label="现金钱包" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  229. <template slot-scope="scope">
  230. <el-select v-model="scope.row.customerWalletId" placeholder="选择现金钱包" size="small" clearable @change="changeXjWallet(scope.$index)">
  231. <el-option
  232. v-for="item in scope.row.wallets"
  233. :key="item.customerWalletId"
  234. :label="item.customerWalletName"
  235. :value="item.customerWalletId">
  236. </el-option>
  237. </el-select>
  238. </template>
  239. </el-table-column>
  240. <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
  241. <template slot-scope="scope">
  242. {{((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}}
  243. </template>
  244. </el-table-column>
  245. <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
  246. <template slot-scope="scope">
  247. <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
  248. </template>
  249. </el-table-column>
  250. <el-table-column align="center" label="直调数量" prop="directTransferQty" min-width="100"></el-table-column>
  251. <el-table-column align="center" label="已发货数量" prop="hasSendQty" min-width="100" show-overflow-tooltip></el-table-column>
  252. <el-table-column align="center" label="已退数量" prop="retiredQty" min-width="100" show-overflow-tooltip></el-table-column>
  253. <el-table-column align="center" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
  254. <template slot-scope="scope">
  255. <el-input v-model="scope.row.remark" size="small"></el-input>
  256. </template>
  257. </el-table-column>
  258. <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
  259. <!-- <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip>
  260. <template slot-scope="scope">
  261. <div>{{ scope.row.status1 | status1Filter }}</div>
  262. </template>
  263. </el-table-column> -->
  264. <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip>
  265. <template slot-scope="scope">
  266. <div>{{ status2Filter(scope.row) }}</div>
  267. </template>
  268. </el-table-column>
  269. <el-table-column align="center" label="业务员" prop="serviceId" min-width="160" show-overflow-tooltip>
  270. <template slot-scope="scope">
  271. <el-select v-model="scope.row.serviceId" placeholder="选择业务员" size="small" clearable>
  272. <el-option
  273. v-for="item in salesmanList"
  274. :key="item.adminUserId"
  275. :label="item.nickName"
  276. :value="item.adminUserId">
  277. </el-option>
  278. </el-select>
  279. </template>
  280. </el-table-column>
  281. <el-table-column align="center" label="操作" width="100" fixed="right">
  282. <template slot-scope="scope">
  283. <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
  284. </template>
  285. </el-table-column>
  286. </el-table>
  287. </div>
  288. <div class="page-footer">
  289. <div class="footer">
  290. <!-- <el-button type="primary" @click="clickSubmitForm(1)">保 存</el-button> -->
  291. <el-button type="primary" @click="clickSubmitForm(2)">提交审核</el-button>
  292. <el-popconfirm title="确定关闭吗?" @onConfirm="goBack" style="margin-left: 10px;">
  293. <el-button slot="reference">关 闭</el-button>
  294. </el-popconfirm>
  295. </div>
  296. </div>
  297. <!-- 工程登录列表 -->
  298. <el-dialog title="工程登录列表" :visible.sync="isShowDialog" width="70%" :close-on-click-modal="false">
  299. <el-form ref="screenForm" :model="screenForm" label-width="0" size="small" label-position="left">
  300. <el-row :gutter="20">
  301. <el-col :xs="24" :sm="12" :lg="6">
  302. <el-form-item prop="enginNum">
  303. <el-input v-model="screenForm.enginNum" placeholder="工程信息单"></el-input>
  304. </el-form-item>
  305. </el-col>
  306. <el-col :xs="24" :sm="12" :lg="6">
  307. <el-form-item prop="enginName">
  308. <el-input v-model="screenForm.enginName" placeholder="工程项目"></el-input>
  309. </el-form-item>
  310. </el-col>
  311. <el-col :xs="24" :sm="12" :lg="6">
  312. <el-form-item prop="company">
  313. <el-input v-model="screenForm.company" placeholder="使用单位"></el-input>
  314. </el-form-item>
  315. </el-col>
  316. <el-col :xs="24" :sm="12" :lg="6" class="tr">
  317. <el-form-item label="">
  318. <el-button size="small" @click="resetScreenForm">清空</el-button>
  319. <el-button size="small" type="primary" @click="submitScreenForm">搜索</el-button>
  320. </el-form-item>
  321. </el-col>
  322. </el-row>
  323. </el-form>
  324. <div class="table" style="margin: 10px 0 20px;">
  325. <el-table
  326. v-loading="dialogTable_listLoading"
  327. :data="dialogTable_dataList"
  328. element-loading-text="Loading"
  329. tooltip-effect="dark"
  330. style="width: 100%"
  331. max-height="270">
  332. <el-table-column align="center" label="" width="100">
  333. <template slot-scope="scope">
  334. <el-button type="primary" size="small" @click="chooseItem(scope.row.enginInfoNo)">选择</el-button>
  335. </template>
  336. </el-table-column>
  337. <el-table-column align="center" prop="orderDate" label="工程登录日期" show-overflow-tooltip></el-table-column>
  338. <el-table-column align="center" prop="enginInfoNo" label="工程信息单" show-overflow-tooltip></el-table-column>
  339. <el-table-column align="center" prop="projectName" label="工程项目" show-overflow-tooltip></el-table-column>
  340. <el-table-column align="center" prop="useUnit" label="使用单位" show-overflow-tooltip></el-table-column>
  341. </el-table>
  342. </div>
  343. <div class="pagination clearfix">
  344. <div class="fr">
  345. <el-pagination
  346. @current-change="dialogTableCurrentChange"
  347. :current-page="dialogTable_currentPage"
  348. :page-size="dialogTable_pageSize"
  349. background
  350. layout="prev, pager, next"
  351. :total="dialogTable_listTotal">
  352. </el-pagination>
  353. </div>
  354. </div>
  355. <div slot="footer" class="dialog-footer">
  356. <el-button @click="isShowDialog = false">关 闭</el-button>
  357. </div>
  358. </el-dialog>
  359. </div>
  360. </template>
  361. <script>
  362. import { getOrderDetail, getComLoginList, getComLoginDetail, getWarehouseList, addCom, editCom, submitCom, checkStock, getWalletList } from "@/api/supply/engin";
  363. import { getDictList, getTypeList, getSalesmanList } from '@/api/common'
  364. import { findElem } from '@/utils/util'
  365. import { mapGetters } from "vuex";
  366. let that
  367. export default {
  368. name: 'CommerceForm',
  369. componentName: 'CommerceForm',
  370. props: ['listItem'],
  371. filters: {
  372. status1Filter(val) {
  373. let STOCK_ORDER_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_START').dictValue;
  374. let STOCK_ORDER_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_END').dictValue;
  375. let STOCK_ORDER_HAVE_START = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_START').dictValue;
  376. let STOCK_ORDER_HAVE_END = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_HAVE_END').dictValue;
  377. let STOCK_ORDER_ALL_NUM = that.stockList.find(o => o.dictCode == 'STOCK_ORDER_ALL_NUM').dictValue;
  378. if (val === '' || val === null || val === undefined) return '未检查';
  379. else if (val <= 0) return '无货';
  380. else if (val > STOCK_ORDER_START && val <= STOCK_ORDER_END) return val;
  381. else if (val >= STOCK_ORDER_HAVE_START && val <= STOCK_ORDER_HAVE_END) return '有货';
  382. else if (val > STOCK_ORDER_ALL_NUM) return '充足';
  383. },
  384. },
  385. data() {
  386. return {
  387. editId: '',
  388. mainForm: {
  389. orderNum: '',
  390. orderDate: '',
  391. // type: '',
  392. jxsNum: '',
  393. jxsName: '',
  394. enginOrderNum: '',
  395. enginName: '',
  396. loginType: '',
  397. factoryNum: '',
  398. company: '',
  399. enginNum: '',
  400. contactMan: '',
  401. tel: '',
  402. phone: '',
  403. address: '',
  404. greeRemark: '',
  405. greeReply: '',
  406. remark: '',
  407. createMan: '',
  408. createDate: '',
  409. fileNum: '',
  410. salesMan: '',
  411. examineRemark: '',
  412. power: '',
  413. },
  414. mainFormRules: {
  415. // orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
  416. jxsNum: [{ required: true, message: '请输入经销商编码', trigger: 'blur' }],
  417. jxsName: [{ required: true, message: '请输入经销商名称', trigger: 'blur' }],
  418. enginOrderNum: [{ required: true, message: '请输入工程登录编号', trigger: 'blur' }],
  419. // enginName: [{ required: true, message: '请输入项目类别', trigger: 'blur' }],
  420. // loginType: [{ required: true, message: '请输入行业类别', trigger: 'blur' }],
  421. company: [{ required: true, message: '请输入使用单位', trigger: 'blur' }],
  422. // contactMan: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
  423. // tel: [{ required: true, message: '请输入固定电话', trigger: 'blur' }],
  424. // phone: [{ required: true, message: '请输入移动电话', trigger: 'blur' }],
  425. address: [{ required: true, message: '请输入安装地址', trigger: 'blur' }],
  426. enginNum: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
  427. },
  428. // typeList: [],
  429. stockList: [],
  430. goodsList: [],
  431. powerList: [],
  432. multipleSelection: [],
  433. isShowDialog: false, // 工程登录列表 - 弹窗
  434. screenForm: {
  435. enginNum: '',
  436. enginName: '',
  437. company: '',
  438. },
  439. dialogTable_dataList: null, // 工程登录列表 - 列表数据
  440. dialogTable_listLoading: true, // 工程登录列表 - 列表加载loading
  441. dialogTable_currentPage: 1, // 工程登录列表 - 当前页码
  442. dialogTable_pageSize: 10, // 工程登录列表 - 每页数量
  443. dialogTable_listTotal: 0, // 工程登录列表 - 列表总数
  444. warehouseList: [],
  445. warehouseValue: '',
  446. isFirst: false,
  447. salesmanList: [],
  448. }
  449. },
  450. computed: {
  451. ...mapGetters(['isCustomer']),
  452. isDealer() {
  453. return JSON.parse(localStorage.getItem("supply_user")).isCustomer
  454. },
  455. outSalesmanList() {
  456. let list = [];
  457. if(this.goodsList && this.goodsList.length) {
  458. this.goodsList.forEach(item => {
  459. if(item.serviceId) {
  460. let hasItem = findElem(list, 'adminUserId', item.serviceId);
  461. if(hasItem < 0) {
  462. let obj = this.salesmanList.find(o => o.adminUserId == item.serviceId);
  463. if(obj) {
  464. list.push(obj);
  465. }
  466. }
  467. }
  468. })
  469. if(this.isFirst) {
  470. this.isFirst = false;
  471. }else {
  472. this.mainForm.salesMan = this.goodsList[0].serviceId;
  473. }
  474. }
  475. return list
  476. }
  477. },
  478. watch: {
  479. goodsList: {
  480. handler(newValue, oldValue) {
  481. if(this.goodsList && this.goodsList.length) {
  482. if(this.isFirst) {
  483. this.isFirst = false;
  484. }else {
  485. // this.mainForm.salesMan = this.goodsList[0].serviceId;
  486. }
  487. }else {
  488. this.mainForm.salesMan = '';
  489. }
  490. },
  491. immediate: true,
  492. deep: true
  493. }
  494. },
  495. beforeCreate() {
  496. that = this;
  497. },
  498. async created() {
  499. await this.getSalesmanList();
  500. this.getDictList();
  501. this.getWarehouseList();
  502. if(this.listItem) {
  503. this.isFirst = true;
  504. this.editId = this.listItem.parentId;
  505. this.getDetail();
  506. }else {
  507. this.mainForm.jxsNum = JSON.parse(localStorage.getItem("supply_user")).customerNumber;
  508. this.mainForm.jxsName = JSON.parse(localStorage.getItem("supply_user")).customerName;
  509. this.mainForm.createMan = JSON.parse(localStorage.getItem("supply_user")).nickName;
  510. this.mainForm.createDate = this.getDate();
  511. }
  512. },
  513. methods: {
  514. // 返回列表
  515. goBack() {
  516. this.$emit('backListFormDetail');
  517. },
  518. getDate() {
  519. var date = new Date();
  520. var seperator1 = "-";
  521. var year = date.getFullYear();
  522. var month = date.getMonth() + 1;
  523. var strDate = date.getDate();
  524. if (month >= 1 && month <= 9) {
  525. month = "0" + month;
  526. }
  527. if (strDate >= 0 && strDate <= 9) {
  528. strDate = "0" + strDate;
  529. }
  530. var currentdate = year + seperator1 + month + seperator1 + strDate;
  531. return currentdate;
  532. },
  533. // 获取产品大类列表
  534. getDictList() {
  535. getDictList({sysDictEnum: 'STOCK_ORDER'}).then(res => {
  536. this.stockList = res.data;
  537. })
  538. getDictList({sysDictEnum: 'POWER_CATEGORY'}).then(res => {
  539. this.powerList = res.data;
  540. })
  541. },
  542. // 获取仓库列表
  543. getWarehouseList() {
  544. getWarehouseList({
  545. pageNum: 1,
  546. pageSize: -1
  547. }).then((res) => {
  548. this.warehouseList = res.data.records;
  549. })
  550. },
  551. async getSalesmanList() {
  552. const res = await getSalesmanList({
  553. pageNum: 1,
  554. pageSize: -1,
  555. isCustomer: 0,
  556. status: true,
  557. });
  558. this.salesmanList = res.data.records;
  559. },
  560. // 获取详情
  561. getDetail() {
  562. getOrderDetail({id: this.editId}).then(res => {
  563. let data = res.data;
  564. this.mainForm.orderNum = data.enginOrderId;
  565. this.mainForm.orderDate = data.orderDate;
  566. // this.mainForm.type = data.mainId;
  567. this.mainForm.jxsNum = data.customerNumber;
  568. this.mainForm.jxsName = data.customerName;
  569. this.mainForm.enginOrderNum = data.refEnginRecordNo;
  570. this.mainForm.enginName = data.refProjectName;
  571. this.mainForm.loginType = data.refTradeCategory;
  572. this.mainForm.factoryNum = data.refFactoryNo;
  573. this.mainForm.company = data.refUseUnit;
  574. this.mainForm.enginNum = data.refProjectNo;
  575. this.mainForm.saleType = data.saleTypeId;
  576. this.mainForm.contactMan = data.refLinkman;
  577. this.mainForm.tel = data.refTel;
  578. this.mainForm.phone = data.refPhone;
  579. this.mainForm.address = data.refInstallAddress;
  580. this.mainForm.greeRemark = data.geLiInerNote;
  581. this.mainForm.greeReply = data.geLiNote;
  582. this.mainForm.remark = data.remark;
  583. this.mainForm.createMan = data.createBy;
  584. this.mainForm.createDate = data.createTime;
  585. this.mainForm.fileNum = data.fileNo;
  586. this.mainForm.salesMan = data.serviceId;
  587. this.mainForm.examineRemark = data.examineNote;
  588. this.mainForm.power = data.refPowerCategory;
  589. data.items.forEach(item => {
  590. item.status1 = '';
  591. item.status2 = '';
  592. item.rebateWallets = item.customerWalletList.filter(item => {
  593. return item.type === 'REBATE';
  594. });
  595. item.wallets = item.customerWalletList.filter(item => {
  596. return item.type === 'COMMONLY';
  597. });
  598. })
  599. this.goodsList = data.items;
  600. })
  601. },
  602. // 工程登录列表 - 获取列表
  603. getComLoginList() {
  604. getComLoginList({
  605. pageNum: this.dialogTable_currentPage,
  606. pageSize: this.dialogTable_pageSize,
  607. enginInfoNo: this.screenForm.enginNum,
  608. projectName: this.screenForm.enginName,
  609. useUnit: this.screenForm.company,
  610. examineStatus: 'OK'
  611. }).then(res => {
  612. this.dialogTable_dataList = res.data.records;
  613. this.dialogTable_listTotal = res.data.total;
  614. this.dialogTable_listLoading = false;
  615. })
  616. },
  617. // 工程登录列表 - 打开弹窗
  618. openShareDetail() {
  619. this.isFirst = true;
  620. this.isShowDialog = true;
  621. this.dialogTable_currentPage = 1;
  622. this.getComLoginList();
  623. },
  624. // 工程登录列表 - 更改列表当前页
  625. dialogTableCurrentChange(val) {
  626. this.dialogTable_currentPage = val;
  627. this.getComLoginList();
  628. },
  629. // 提交筛选表单
  630. submitScreenForm() {
  631. this.dialogTable_currentPage = 1;
  632. this.getComLoginList();
  633. },
  634. // 重置筛选表单
  635. resetScreenForm() {
  636. this.$refs.screenForm.resetFields();
  637. this.dialogTable_currentPage = 1;
  638. this.getComLoginList();
  639. },
  640. // 选择工程登录
  641. chooseItem(id) {
  642. getComLoginDetail({
  643. recordNo: id,
  644. enginOrderId: this.mainForm.orderNum
  645. }).then(res => {
  646. this.isShowDialog = false;
  647. let data = res.data;
  648. this.mainForm.enginOrderNum = data.enginInfoNo;
  649. this.mainForm.enginName = data.projectName;
  650. this.mainForm.loginType = data.tradeCategory;
  651. this.mainForm.factoryNum = data.factoryNo;
  652. this.mainForm.company = data.useUnit;
  653. this.mainForm.enginNum = data.projectNo;
  654. this.mainForm.contactMan = data.linkman;
  655. this.mainForm.tel = data.tel;
  656. this.mainForm.phone = data.phone;
  657. this.mainForm.address = data.installAddress;
  658. this.mainForm.salesMan = data.serviceId;
  659. this.mainForm.power = data.powerCategory;
  660. this.mainForm.remark = data.remark;
  661. this.mainForm.greeRemark = data.geLiInerNote;
  662. this.mainForm.greeReply = data.geLiNote;
  663. this.goodsList = data.items.map(item => {
  664. return {
  665. useRefCount: item.useRefCount,
  666. saleTypeId: item.saleTypeId,
  667. saleTypeCode: item.saleTypeCode,
  668. saleTypeName: item.saleTypeName,
  669. materialId: item.materialId,
  670. materialNumber: item.materialNumber,
  671. materialOldNumber: item.materialOldNumber,
  672. materialName: item.materialName,
  673. specification: item.specification,
  674. enginNum: item.qty,
  675. enginPrice: item.price,
  676. enginTotality: item.totalAmount,
  677. historyHasDeliverQty: item.hasDeliverQty,
  678. unit: item.unit,
  679. price: item.price,
  680. qty: item.qty,
  681. customerWalletId2: '',
  682. rebateRate: '',
  683. discAmount: '',
  684. customerWalletId: '',
  685. isDirectTransfer: false,
  686. directTransferQty: '',
  687. hasSendQty: '',
  688. remark: item.remark,
  689. tax: item.taxRate,
  690. status1: '',
  691. status2: '',
  692. serviceId: '',
  693. serviceName: '',
  694. rebateWallets: item.customerWalletList.filter(item => {
  695. return item.type === 'REBATE';
  696. }),
  697. wallets: item.customerWalletList.filter(item => {
  698. return item.type === 'COMMONLY';
  699. }),
  700. }
  701. })
  702. this.goodsList.forEach(item => {
  703. item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
  704. item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
  705. item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
  706. })
  707. })
  708. },
  709. // 删除产品
  710. deleteItem(index) {
  711. this.goodsList.splice(index, 1);
  712. },
  713. // 修改返利钱包
  714. changeFlWallet(index) {
  715. if(this.goodsList[index].customerWalletId2) {
  716. let obj = this.goodsList[index].rebateWallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId2);
  717. this.goodsList[index].rebateRate = obj.rebateRate;
  718. this.goodsList[index].customerWalletName2 = obj.customerWalletName;
  719. }else {
  720. this.goodsList[index].rebateRate = '';
  721. this.goodsList[index].customerWalletName2 = '';
  722. }
  723. },
  724. // 修改现金钱包
  725. changeXjWallet(index) {
  726. if(this.goodsList[index].customerWalletId) {
  727. let obj = this.goodsList[index].wallets.find(o => o.customerWalletId == this.goodsList[index].customerWalletId);
  728. this.goodsList[index].customerWalletName = obj.customerWalletName;
  729. if (index === 1) {
  730. this.goodsList[index].serviceId = obj.serviceId;
  731. this.goodsList[index].serviceName = obj.serviceName;
  732. }
  733. }else {
  734. this.goodsList[index].customerWalletName = '';
  735. this.goodsList[index].serviceId = '';
  736. this.goodsList[index].serviceName = '';
  737. }
  738. },
  739. // 检查库存
  740. checkStock() {
  741. if(!this.warehouseValue) {
  742. return this.$errorMsg('请选择仓库');
  743. }
  744. if(!this.goodsList) {
  745. return this.$errorMsg('请添加货品');
  746. }
  747. let ids = [];
  748. this.goodsList.forEach(item => {
  749. ids.push(item.materialId);
  750. })
  751. checkStock({
  752. correspondId: this.warehouseValue,
  753. materialId: ids.join(',')
  754. }).then(res => {
  755. if(res.data) {
  756. this.goodsList.forEach((item, index) => {
  757. item.status1 = res.data[index].allStockNum;
  758. item.status2 = res.data[index].stockNum;
  759. })
  760. }
  761. })
  762. },
  763. status2Filter(item) {
  764. if (item.status2 === '' || item.status2 === null || item.status2 === undefined) return '未检查';
  765. else if (item.status2 <= 0) return '无货';
  766. else if (item.status2 >= item.qty) return '可用';
  767. else return '短缺';
  768. },
  769. handleSelectionChange(val) {
  770. this.multipleSelection = val;
  771. },
  772. // 保存 / 提交审核
  773. clickSubmitForm(type) {
  774. this.$refs.mainForm.validate((valid) => {
  775. if (valid) {
  776. if(this.goodsList.length < 1) {
  777. return this.$errorMsg('请添加产品');
  778. }
  779. if(this.multipleSelection.length < 1) {
  780. return this.$errorMsg('请选择产品');
  781. }
  782. for(let i=0; i<this.multipleSelection.length; i++) {
  783. if(!this.multipleSelection[i].customerWalletId) {
  784. this.$errorMsg('请选择现金钱包');
  785. return;
  786. }
  787. if(!this.multipleSelection[i].qty) {
  788. this.$errorMsg('请输入数量');
  789. return;
  790. }
  791. if(this.multipleSelection[i].qty > this.multipleSelection[i].enginNum) {
  792. this.$errorMsg('数量不能大于工程信息数量');
  793. return;
  794. }
  795. }
  796. let goodsList = JSON.parse(JSON.stringify(this.multipleSelection));
  797. goodsList.forEach(item => {
  798. delete item.rebateWallets;
  799. delete item.wallets;
  800. })
  801. let saleManItem = this.mainForm.salesMan ? this.salesmanList.find(o => o.adminUserId == this.mainForm.salesMan) : '';
  802. let params = {
  803. enginOrderId: this.mainForm.orderNum,
  804. // orderDate: this.mainForm.orderDate,
  805. // mainId: this.mainForm.type || '',
  806. refEnginRecordNo: this.mainForm.enginOrderNum || '',
  807. refProjectName: this.mainForm.enginName || '',
  808. refTradeCategory: this.mainForm.loginType || '',
  809. refFactoryNo: this.mainForm.factoryNum || '',
  810. refUseUnit: this.mainForm.company || '',
  811. refProjectNo: this.mainForm.enginNum || '',
  812. refLinkman: this.mainForm.contactMan || '',
  813. refTel: this.mainForm.tel || '',
  814. refPhone: this.mainForm.phone || '',
  815. refInstallAddress: this.mainForm.address || '',
  816. geLiInerNote: this.mainForm.greeRemark || '',
  817. geLiNote: this.mainForm.greeReply || '',
  818. remark: this.mainForm.remark || '',
  819. fileNo: this.mainForm.fileNum || '',
  820. serviceId: this.mainForm.salesMan,
  821. serviceName: saleManItem ? saleManItem.nickName : goodsList[0].serviceName,
  822. refPowerCategory: this.mainForm.power,
  823. items: goodsList,
  824. }
  825. if(type === 1) {
  826. if(this.listItem) {
  827. editCom(params).then(res => {
  828. this.$successMsg('编辑成功');
  829. this.goBack();
  830. this.$parent.getList();
  831. })
  832. }else {
  833. addCom(params).then(res => {
  834. this.$successMsg('新增成功');
  835. this.goBack();
  836. this.$parent.getList();
  837. })
  838. }
  839. }else if(type === 2) {
  840. submitCom(params).then(res => {
  841. this.$successMsg('提交审核成功');
  842. this.goBack();
  843. this.$parent.getList();
  844. })
  845. }
  846. }
  847. })
  848. },
  849. }
  850. }
  851. </script>
  852. <style scoped lang="scss">
  853. .detail-container {
  854. width: 100%;
  855. height: 100%;
  856. }
  857. .main-title {
  858. display: flex;
  859. justify-content: space-between;
  860. align-items: center;
  861. margin-top: 20px;
  862. height: 60px;
  863. border-bottom: 1px solid #DCDFE6;
  864. margin-bottom: 20px;
  865. .title {
  866. font-size: 16px;
  867. font-weight: 600;
  868. padding-left: 10px;
  869. }
  870. }
  871. ::v-deep input::-webkit-outer-spin-button,
  872. ::v-deep input::-webkit-inner-spin-button {
  873. -webkit-appearance: none;
  874. }
  875. ::v-deep input[type='number'] {
  876. -moz-appearance: textfield;
  877. }
  878. </style>