commerce_form.vue 34 KB

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