e2502e2587dd3da5137db2867f4eb29aeb15943a.svn-base 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" @click="handleCreate">新增</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" @click="handleDelete">删除</el-button>
  6. <el-button class="success" @click="handleFeedBank">饲料库</el-button>
  7. </div>
  8. <div class="search">
  9. <el-input v-model="table.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  10. <el-select v-model="table.getdataListParm.parammaps.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 150px;" clearable>
  11. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
  14. <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  18. </el-select>
  19. <div ref="selectInput" class="filter-item selectInput">
  20. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  21. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  22. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  23. <ul v-if="arrowUp" class="selectUl">
  24. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio"type="text" style="width: 245px;" /></li>
  25. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  26. <li>
  27. <a>跳转延时</a>
  28. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 245px;" clearable>
  29. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. </li>
  32. <li>
  33. <div style="float: right;">
  34. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  35. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  36. </div>
  37. </li>
  38. </ul>
  39. </div>
  40. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  41. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  42. </div>
  43. <div class="table">
  44. <el-table
  45. :key="table.tableKey"
  46. v-loading="table.listLoading"
  47. element-loading-text="给我一点时间"
  48. :data="table.list"
  49. border
  50. fit
  51. highlight-current-row
  52. style="width: 100%;"
  53. :row-style="rowStyle"
  54. :cell-style="cellStyle"
  55. class="elTable table-fixed"
  56. @selection-change="handleSelectionChange"
  57. >
  58. <el-table-column type="selection" align="center" width="50" />
  59. <el-table-column label="序号" align="center" type="index" width="50px">
  60. <template slot-scope="scope">
  61. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="饲料名称" min-width="130px" align="center">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.fname }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="饲料分类" min-width="130px" align="center">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.fclass }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="唯一编码" min-width="110px" align="center">
  75. <template slot-scope="scope">
  76. <span>{{ scope.row.feedcode }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="饲料来源" min-width="110px" align="center">
  80. <template slot-scope="scope">
  81. <span>{{ scope.row.source }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="计划类型" min-width="110px" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.printgroup }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="小料称" min-width="110px" align="center">
  90. <template slot-scope="scope">
  91. <span>{{ scope.row.smtmrname }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="允许误差数(kg)" min-width="110px" align="center">
  95. <template slot-scope="scope">
  96. <span>{{ scope.row.allowratio }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="包装单位重量(kg)" min-width="110px" align="center">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.unitweight }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="单价" min-width="110px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.uprice }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="跳转重量域(kg)" min-width="110px" align="center">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.autozone }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="跳转延时" min-width="110px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.autosecondname }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="确认开始" min-width="110px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.confirmstartname }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="继电器位置" min-width="110px" align="center">
  125. <template slot-scope="scope">
  126. <span>{{ scope.row.trgaddress }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="备用字段01" min-width="110px" align="center">
  130. <template slot-scope="scope">
  131. <span>{{ scope.row.backup1 }}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="备用字段02" min-width="110px" align="center">
  135. <template slot-scope="scope">
  136. <span>{{ scope.row.backup2 }}</span>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="备用字段03" min-width="110px" align="center">
  140. <template slot-scope="scope">
  141. <span>{{ scope.row.backup3 }}</span>
  142. </template>
  143. </el-table-column>
  144. <el-table-column label="是否启用" min-width="110px" align="center">
  145. <template slot-scope="scope">
  146. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  150. <template slot-scope="{row}">
  151. <el-button class="miniSuccess" @click="handleNutritive (row)">营养价值</el-button>
  152. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleRelation(row)">关联</el-button>
  153. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  154. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  159. </div>
  160. <!-- 新增/编辑 -->
  161. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  162. <div class="app-add">
  163. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  164. <el-row>
  165. <el-col :span="24">
  166. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  167. </el-col>
  168. </el-row>
  169. <el-row>
  170. <el-col :span="6">
  171. <el-form-item label="饲料名称:" prop="fname">
  172. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
  173. </el-form-item>
  174. </el-col>
  175. <el-col :span="6">
  176. <el-form-item label="饲料类别:" prop="fclassid">
  177. <el-select v-model="create.temp.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 100%;" @change="changeFeedList">
  178. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  179. </el-select>
  180. </el-form-item></el-col>
  181. <el-col :span="6">
  182. <el-form-item label="唯一编码:" prop="feedcode">
  183. <el-input ref="feedcode" v-model="create.temp.feedcode" class="filter-item" placeholder="请输入唯一编码" type="text" />
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="6">
  187. <el-form-item label="饲料来源:" prop="source">
  188. <el-input ref="source" v-model="create.temp.source" class="filter-item" disabled placeholder="用户自定义" type="text" />
  189. </el-form-item>
  190. </el-col>
  191. </el-row>
  192. <el-row>
  193. <el-col :span="6">
  194. <el-form-item label="计划类型:" prop="printgroupid">
  195. <el-select v-model="create.temp.printgroupid" filterable placeholder="计划类型" class="filter-item" style="width: 100%;" @change="changePlanList">
  196. <el-option v-for="item in planTypeList" :key="item.value" :label="item.label" :value="item.value" />
  197. </el-select>
  198. </el-form-item>
  199. </el-col>
  200. <el-col :span="6">
  201. <el-form-item label="包装单位重量(kg):" prop="unitweight">
  202. <el-input ref="unitweight" v-model="create.temp.unitweight" class="filter-item" placeholder="正整数" type="number" style="width: 100%;" />
  203. </el-form-item>
  204. </el-col>
  205. <el-col :span="6">
  206. <el-form-item label="单价:" prop="uprice">
  207. <el-input ref="uprice" v-model="create.temp.uprice" v-limit class="filter-item" placeholder="最多俩位小数" type="number" step="0.01" style="width: 100%;" />
  208. </el-form-item>
  209. </el-col>
  210. </el-row>
  211. <el-row>
  212. <el-col :span="24">
  213. <h3 style="width: 160px;text-align: right;">搅拌参数</h3>
  214. </el-col>
  215. </el-row>
  216. <el-row>
  217. <el-col :span="6">
  218. <el-form-item label="允许误差数(kg):" prop="allowratio">
  219. <el-input ref="allowratio" v-model="create.temp.allowratio" class="filter-item" placeholder="正整数" type="text" />
  220. </el-form-item>
  221. </el-col>
  222. <el-col :span="6">
  223. <el-form-item label="跳转重量域(kg):" prop="autozone">
  224. <el-input ref="autozone" v-model="create.temp.autozone" :disabled="create.temp.autosecond=='0'" class="filter-item" placeholder="0-20之间的整数" type="text" />
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="6">
  228. <el-form-item label="跳转延时:" prop="autosecond">
  229. <el-select v-model="create.temp.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 100%;" @change="changeAutosecond">
  230. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  231. </el-select>
  232. </el-form-item>
  233. </el-col>
  234. <el-col :span="6">
  235. <el-form-item label="确认开始:" prop="confirmstart">
  236. <el-select v-model="create.temp.confirmstart" filterabler placeholde="确认开始" class="filter-item" style="width: 100%;" @change="changeConfirmstart">
  237. <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.id" />
  238. </el-select>
  239. </el-form-item>
  240. </el-col>
  241. </el-row>
  242. <el-row>
  243. <el-col :span="6">
  244. <el-form-item label="是否启用:" prop="enable">
  245. <el-select v-model="create.temp.enable" filterable placeholder="是否启用" class="filter-item" style="width: 100%;">
  246. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </el-form-item>
  249. </el-col>
  250. <el-col :span="6">
  251. <el-form-item label="继电器位置:" prop="trgaddress">
  252. <el-input ref="trgaddress" v-model="create.temp.trgaddress" class="filter-item" placeholder="继电器位置" type="number" />
  253. </el-form-item>
  254. </el-col>
  255. <el-col :span="6">
  256. <el-form-item label="小料称:" prop="smtmrid">
  257. <el-select v-model="create.temp.smtmrid" filterable placeholder="小料称" clearable class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  258. <el-option v-for="item in smallMaterialList" :key="item.id" :label="item.tname" :value="item.id" />
  259. </el-select>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. <el-row>
  264. <h3 style="width: 160px;text-align: right;">备用字段</h3>
  265. </el-row>
  266. <el-row>
  267. <el-col :span="6">
  268. <el-form-item label="备用字段01:" prop="backup1">
  269. <el-input ref="backup1" v-model="create.temp.backup1" class="filter-item" placeholder="备用字段01" type="text" />
  270. </el-form-item>
  271. </el-col>
  272. <el-col :span="6">
  273. <el-form-item label="备用字段02:" prop="backup2">
  274. <el-input ref="backup2" v-model="create.temp.backup2" class="filter-item" placeholder="备用字段02" type="text" />
  275. </el-form-item>
  276. </el-col>
  277. <el-col :span="6">
  278. <el-form-item label="备用字段03:" prop="backup3">
  279. <el-input ref="backup3" v-model="create.temp.backup3" class="filter-item" placeholder="备用字段03" type="text" />
  280. </el-form-item>
  281. </el-col>
  282. </el-row>
  283. </el-form>
  284. <div slot="footer" class="dialog-footer">
  285. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  286. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  287. </div>
  288. </div>
  289. </el-dialog>
  290. <!-- 饲料库 -->
  291. <el-dialog :title="textMap[feedBank.dialogStatus]" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
  292. <div class="app-add">
  293. <div class="search">
  294. <el-input v-model="feedBank.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  295. <el-select v-model="feedBank.getdataListParm.parammaps.statue" filterabler placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
  296. <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.id" />
  297. </el-select>
  298. <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
  299. <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
  300. </div>
  301. <div class="table">
  302. <el-table
  303. :key="feedBank.tableKey"
  304. v-loading="feedBank.listLoading"
  305. element-loading-text="给我一点时间"
  306. :data="feedBank.list"
  307. border
  308. fit
  309. highlight-current-row
  310. style="width: 100%;margin: 0 auto 50px;"
  311. :row-style="rowStyle"
  312. :cell-style="cellStyle"
  313. class="elTable table-fixed"
  314. >
  315. <el-table-column label="序号" align="center" type="index" width="50px" />
  316. <el-table-column label="来源" min-width="90" align="center">
  317. <template slot-scope="scope">
  318. <span>{{ scope.row.sources }}</span>
  319. </template>
  320. </el-table-column>
  321. <el-table-column label="中国饲料号" min-width="100px" align="center">
  322. <template slot-scope="scope">
  323. <span>{{ scope.row.feedcode }}</span>
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="饲料名称" min-width="90px" align="center">
  327. <template slot-scope="scope">
  328. <span>{{ scope.row.fname }}</span>
  329. </template>
  330. </el-table-column>
  331. <el-table-column label="价格" min-width="80px" align="center">
  332. <template slot-scope="scope">
  333. <span>{{ scope.row.price }}</span>
  334. </template>
  335. </el-table-column>
  336. <el-table-column label="样品说明" min-width="90px" align="center">
  337. <template slot-scope="scope">
  338. <span>{{ scope.row.remark }}</span>
  339. </template>
  340. </el-table-column>
  341. <el-table-column label="干物质(DM%)" min-width="70px" align="center">
  342. <template slot-scope="scope">
  343. <span>{{ scope.row.dry }}</span>
  344. </template>
  345. </el-table-column>
  346. <el-table-column label="淀粉(%DM)" min-width="70px" align="center">
  347. <template slot-scope="scope">
  348. <span>{{ scope.row.starch }}</span>
  349. </template>
  350. </el-table-column>
  351. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  352. <template slot-scope="scope">
  353. <span>{{ scope.row.cp }}</span>
  354. </template>
  355. </el-table-column>
  356. <el-table-column label="钙(Ca%DM)" min-width="80px" align="center">
  357. <template slot-scope="scope">
  358. <span>{{ scope.row.ca }}</span>
  359. </template>
  360. </el-table-column>
  361. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  362. <template slot-scope="scope">
  363. <span>{{ scope.row.p }}</span>
  364. </template>
  365. </el-table-column>
  366. <el-table-column label="产奶净能(%DM)" min-width="80px" align="center">
  367. <template slot-scope="scope">
  368. <span>{{ scope.row.n }}</span>
  369. </template>
  370. </el-table-column>
  371. <el-table-column label="脂肪(%DM)" min-width="70px" align="center">
  372. <template slot-scope="scope">
  373. <span>{{ scope.row.fat }}</span>
  374. </template>
  375. </el-table-column>
  376. <el-table-column label="ADF(%DM)" min-width="80px" align="center">
  377. <template slot-scope="scope">
  378. <span>{{ scope.row.adf }}</span>
  379. </template>
  380. </el-table-column>
  381. <el-table-column label="NDF(%DM)" min-width="80px" align="center">
  382. <template slot-scope="scope">
  383. <span>{{ scope.row.ndf }}</span>
  384. </template>
  385. </el-table-column>
  386. <el-table-column label="NDIP%" min-width="80px" align="center">
  387. <template slot-scope="scope">
  388. <span>{{ scope.row.ndip }}</span>
  389. </template>
  390. </el-table-column>
  391. <el-table-column label="粗灰分(Ash%)" min-width="70px" align="center">
  392. <template slot-scope="scope">
  393. <span>{{ scope.row.ash }}</span>
  394. </template>
  395. </el-table-column>
  396. <el-table-column label="粗料" min-width="70px" align="center">
  397. <template slot-scope="scope">
  398. <span>{{ scope.row.iscu }}</span>
  399. </template>
  400. </el-table-column>
  401. <el-table-column label="关联状态" min-width="70px" align="center">
  402. <template slot-scope="scope">
  403. <span v-if="scope.row.statue==0">否</span>
  404. <span v-if="scope.row.statue==1">是</span>
  405. </template>
  406. </el-table-column>
  407. </el-table>
  408. </div>
  409. <div slot="footer" class="dialog-footer">
  410. <el-button class="cancelClose" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
  411. </div>
  412. </div>
  413. </el-dialog>
  414. <!-- 关联 -->
  415. <el-dialog :title="textMap[relation.dialogStatus]" :visible.sync="relation.dialogFormVisible" :close-on-click-modal="false" width="90%">
  416. <div class="app-add">
  417. <div class="search">
  418. <el-input v-model="relation.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  419. <el-button class="successBorder" @click="handleRelationSearch">查询</el-button>
  420. </div>
  421. <div class="table">
  422. <el-table
  423. :key="relation.tableKey"
  424. v-loading="relation.listLoading"
  425. element-loading-text="给我一点时间"
  426. :data="relation.list"
  427. border
  428. fit
  429. highlight-current-row
  430. style="width: 100%;margin: 0 auto 50px;"
  431. :row-style="rowStyle"
  432. :cell-style="cellStyle"
  433. class="elTable table-fixed"
  434. >
  435. <el-table-column label="序号" align="center" type="index" width="50px" />
  436. <el-table-column label="来源" min-width="90" align="center">
  437. <template slot-scope="scope">
  438. <span>{{ scope.row.sources }}</span>
  439. </template>
  440. </el-table-column>
  441. <el-table-column label="中国饲料号" min-width="100px" align="center">
  442. <template slot-scope="scope">
  443. <span>{{ scope.row.feedcode }}</span>
  444. </template>
  445. </el-table-column>
  446. <el-table-column label="饲料名称" min-width="90px" align="center">
  447. <template slot-scope="scope">
  448. <span>{{ scope.row.fname }}</span>
  449. </template>
  450. </el-table-column>
  451. <el-table-column label="价格" min-width="80px" align="center">
  452. <template slot-scope="scope">
  453. <span>{{ scope.row.price }}</span>
  454. </template>
  455. </el-table-column>
  456. <el-table-column label="样品说明" min-width="90px" align="center">
  457. <template slot-scope="scope">
  458. <span>{{ scope.row.remark }}</span>
  459. </template>
  460. </el-table-column>
  461. <el-table-column label="干物质(DM%)" min-width="70px" align="center">
  462. <template slot-scope="scope">
  463. <span>{{ scope.row.dry }}</span>
  464. </template>
  465. </el-table-column>
  466. <el-table-column label="淀粉(%DM)" min-width="70px" align="center">
  467. <template slot-scope="scope">
  468. <span>{{ scope.row.starch }}</span>
  469. </template>
  470. </el-table-column>
  471. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  472. <template slot-scope="scope">
  473. <span>{{ scope.row.cp }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column label="钙(Ca%DM)" min-width="80px" align="center">
  477. <template slot-scope="scope">
  478. <span>{{ scope.row.ca }}</span>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  482. <template slot-scope="scope">
  483. <span>{{ scope.row.p }}</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="产奶净能(%DM)" min-width="80px" align="center">
  487. <template slot-scope="scope">
  488. <span>{{ scope.row.n }}</span>
  489. </template>
  490. </el-table-column>
  491. <el-table-column label="脂肪(%DM)" min-width="70px" align="center">
  492. <template slot-scope="scope">
  493. <span>{{ scope.row.fat }}</span>
  494. </template>
  495. </el-table-column>
  496. <el-table-column label="ADF(%DM)" min-width="80px" align="center">
  497. <template slot-scope="scope">
  498. <span>{{ scope.row.adf }}</span>
  499. </template>
  500. </el-table-column>
  501. <el-table-column label="NDF(%DM)" min-width="80px" align="center">
  502. <template slot-scope="scope">
  503. <span>{{ scope.row.ndf }}</span>
  504. </template>
  505. </el-table-column>
  506. <el-table-column label="NDIP%" min-width="80px" align="center">
  507. <template slot-scope="scope">
  508. <span>{{ scope.row.ndip }}</span>
  509. </template>
  510. </el-table-column>
  511. <el-table-column label="粗灰分(Ash%)" min-width="70px" align="center">
  512. <template slot-scope="scope">
  513. <span>{{ scope.row.ash }}</span>
  514. </template>
  515. </el-table-column>
  516. <el-table-column label="粗料" min-width="70px" align="center">
  517. <template slot-scope="scope">
  518. <span>{{ scope.row.iscu }}</span>
  519. </template>
  520. </el-table-column>
  521. <el-table-column label="操作" min-width="150px" align="center" class-name="small-padding fixed-width" fixed="right">
  522. <template slot-scope="{row}">
  523. <el-button v-if="row.statueRelation == '1'" class="miniSuccess" :disabled="isokDisable" @click="disassociateData(row)">取消关联</el-button>
  524. <el-button v-if="row.statueRelation == '0'" class="miniSuccess" :disabled="isokDisable" @click="relationData(row)">关联</el-button>
  525. </template>
  526. </el-table-column>
  527. </el-table>
  528. </div>
  529. <div slot="footer" class="dialog-footer">
  530. <el-button class="cancelClose" @click="relation.dialogFormVisible = false;getList() ">关闭</el-button>
  531. </div>
  532. </div>
  533. </el-dialog>
  534. <!-- 营养价值 -->
  535. <el-dialog :title="textMap[nutritive.dialogStatus]" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
  536. <div class="app-add">
  537. <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
  538. <el-row>
  539. <el-col :span="6">
  540. <el-form-item label="干物质(DM%):" prop="dry">
  541. <el-input ref="dry" v-model="nutritive.temp.dry" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入干物质" type="number" step="0.01" />
  542. </el-form-item>
  543. </el-col>
  544. <el-col :span="6">
  545. <el-form-item label="淀粉(%DM):" prop="starch">
  546. <el-input ref="starch" v-model="nutritive.temp.starch" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入淀粉" type="number" step="0.01" />
  547. </el-form-item>
  548. </el-col>
  549. <el-col :span="6">
  550. <el-form-item label="粗蛋白(CP%DM):" prop="cp">
  551. <el-input ref="cp" v-model="nutritive.temp.cp" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗蛋白" type="number" step="0.01" />
  552. </el-form-item>
  553. </el-col>
  554. <el-col :span="6">
  555. <el-form-item label="钙(Ca%DM):" prop="ca">
  556. <el-input ref="ca" v-model="nutritive.temp.ca" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入钙" type="number" step="0.01" />
  557. </el-form-item>
  558. </el-col>
  559. </el-row>
  560. <el-row>
  561. <el-col :span="6">
  562. <el-form-item label="磷(P%DM):" prop="p">
  563. <el-input ref="p" v-model="nutritive.temp.p" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入磷" type="number" step="0.01" />
  564. </el-form-item>
  565. </el-col>
  566. <el-col :span="6">
  567. <el-form-item label="产奶净能(%DM):" prop="n">
  568. <el-input ref="n" v-model="nutritive.temp.n" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入产奶净能" type="number" step="0.01" />
  569. </el-form-item>
  570. </el-col>
  571. <el-col :span="6">
  572. <el-form-item label="脂肪(%DM):" prop="fat">
  573. <el-input ref="fat" v-model="nutritive.temp.fat" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入脂肪" type="number" step="0.01" />
  574. </el-form-item>
  575. </el-col>
  576. <el-col :span="6">
  577. <el-form-item label="ADF(%DM):" prop="adf">
  578. <el-input ref="adf" v-model="nutritive.temp.adf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入ADF" type="number" step="0.01" />
  579. </el-form-item>
  580. </el-col>
  581. </el-row>
  582. <el-row>
  583. <el-col :span="6">
  584. <el-form-item label="NDF(%DM):" prop="ndf">
  585. <el-input ref="ndf" v-model="nutritive.temp.ndf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDF" type="number" step="0.01" />
  586. </el-form-item>
  587. </el-col>
  588. <el-col :span="6">
  589. <el-form-item label="NDIP(%):" prop="ndip">
  590. <el-input ref="ndip" v-model="nutritive.temp.ndip" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDIP" type="number" step="0.01" />
  591. </el-form-item>
  592. </el-col>
  593. <el-col :span="6">
  594. <el-form-item label="粗灰分(Ash%):" prop="ash">
  595. <el-input ref="ash" v-model="nutritive.temp.ash" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗灰分" type="number" min="0.00" step="0.01" />
  596. </el-form-item>
  597. </el-col>
  598. </el-row>
  599. </el-form>
  600. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  601. <el-button @click="nutritive.dialogFormVisible = false;getList()">关闭</el-button>
  602. <el-button v-if="nutritive.dialogStatus==='nutritive' && isRoleEdit" type="success" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
  603. </div>
  604. </div>
  605. </el-dialog>
  606. </div>
  607. </template>
  608. <script>
  609. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  610. import Cookies from 'js-cookie'
  611. import Pagination from '@/components/Pagination'
  612. import { MessageBox } from 'element-ui'
  613. export default {
  614. name: 'FeedTable',
  615. components: { Pagination },
  616. directives: {
  617. limit: {
  618. // 指令的定义
  619. update: function(el) {
  620. el.onkeypress = function(e) {
  621. var code = e.charCode
  622. if (code != 0) {
  623. if (!String.fromCharCode(code).match(/[0-9\.]/)) {
  624. return false
  625. }
  626. }
  627. }
  628. el.addEventListener('textInput', function(e) {
  629. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  630. })
  631. el.onkeyup = function(e) {
  632. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  633. }
  634. }
  635. }
  636. },
  637. data() {
  638. return {
  639. isRoleEdit: [],
  640. requestParams: [
  641. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  642. { name: 'getFeedclassByBig', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  643. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['计划类型'] },
  644. { name: 'getTMRListEnableType', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), eqtype: '4' }}
  645. ],
  646. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 是否启用
  647. feedSourcesList: [{ id: '0', name: '系统内置' }, { id: '1', name: '用户自定义' }], // 饲料来源
  648. confirmStartList: [{ id: '0', name: '禁用' }, { id: '1', name: '启用' }], // 确认开始
  649. associationStatusList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 关联状态
  650. jumpDelayList: [], // 跳转延时
  651. feedTypeList: [], // 饲料分类
  652. planTypeList: [], // 计划类型
  653. smallMaterialList: [], // 小料称
  654. table: {
  655. tableKey: 0,
  656. list: [],
  657. total: 0,
  658. listLoading: true,
  659. getdataListParm: {
  660. name: 'getFeedList',
  661. page: 1,
  662. offset: 1,
  663. pagecount: 10,
  664. returntype: 'Map',
  665. parammaps: {
  666. pastureid: Cookies.get('pastureid'),
  667. fname: '',
  668. fclassid: '',
  669. source: '',
  670. autozone: '',
  671. autosecond: '',
  672. allowratio: '',
  673. printgroup: '',
  674. enable: ''
  675. }
  676. }
  677. },
  678. // 多项搜索显示隐藏
  679. arrowDown: true,
  680. arrowUp: false,
  681. // 新增/编辑
  682. create: {
  683. dialogFormVisible: false,
  684. dialogStatus: '',
  685. temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' },
  686. rules: {
  687. fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  688. fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  689. feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  690. }
  691. },
  692. // 饲料库
  693. feedBank: {
  694. dialogFormVisible: false,
  695. dialogStatus: '',
  696. temp: {},
  697. rules: {},
  698. tableKey: 0,
  699. list: [],
  700. total: 0,
  701. listLoading: true,
  702. getdataListParm: {
  703. name: 'getFeednurList',
  704. page: 1,
  705. offset: 1,
  706. returntype: 'Map',
  707. parammaps: {
  708. pastureid: Cookies.get('pastureid'),
  709. fname: '',
  710. statue: ''
  711. }
  712. }
  713. },
  714. // 关联
  715. relation: {
  716. dialogFormVisible: false,
  717. dialogStatus: '',
  718. temp: {},
  719. rules: {},
  720. tableKey: 0,
  721. list: [],
  722. total: 0,
  723. listLoading: true,
  724. getdataListParm: {
  725. name: 'getFeednurRelation',
  726. page: 1,
  727. offset: 1,
  728. returntype: 'Map',
  729. parammaps: {
  730. pastureid: Cookies.get('pastureid'),
  731. fname: ''
  732. }
  733. }
  734. },
  735. // 营养价值
  736. nutritive: {
  737. dialogFormVisible: false,
  738. dialogStatus: '',
  739. temp: {},
  740. rules: {}
  741. },
  742. textMap: {
  743. create: '新增',
  744. update: '编辑',
  745. feedBank: '饲料库',
  746. relation: '关联',
  747. nutritive: '营养价值'
  748. },
  749. isokDisable: false,
  750. selectList: [],
  751. requestParam: {},
  752. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  753. cellStyle: { padding: 0 + 'px' }
  754. }
  755. },
  756. mounted() {
  757. document.addEventListener('click', (e) => {
  758. if (this.$refs.selectInput !== undefined) {
  759. if (!this.$refs.selectInput.contains(e.target)) {
  760. this.arrowDown = true
  761. this.arrowUp = false
  762. } else {
  763. this.arrowDown = false
  764. this.arrowUp = true
  765. }
  766. }
  767. })
  768. },
  769. created() {
  770. this.getList()
  771. this.getDownList()
  772. this.getButtons()
  773. },
  774. methods: {
  775. getButtons() {
  776. const Edit = 'FeedTable'
  777. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  778. this.isRoleEdit = isRoleEdit
  779. },
  780. getDownList() {
  781. GetDataByNames(this.requestParams).then(response => {
  782. this.jumpDelayList = response.data.getDictByName.list
  783. this.feedTypeList = response.data.getFeedclassByBig.list
  784. this.planTypeList = response.data.getDictByName2.list
  785. this.smallMaterialList = response.data.getTMRListEnableType.list
  786. })
  787. },
  788. getList() {
  789. this.table.listLoading = true
  790. GetDataByName(this.table.getdataListParm).then(response => {
  791. console.log('table数据', response.data.list)
  792. if (response.data.list !== null) {
  793. this.table.list = response.data.list
  794. this.table.pageNum = response.data.pageNum
  795. this.table.pageSize = response.data.pageSize
  796. this.table.total = response.data.total
  797. } else {
  798. this.table.list = []
  799. }
  800. setTimeout(() => {
  801. this.table.listLoading = false
  802. }, 100)
  803. })
  804. },
  805. handleSearch() {
  806. console.log('点击了查询')
  807. this.table.getdataListParm.offset = 1
  808. this.getList()
  809. this.arrowDown = true
  810. this.arrowUp = false
  811. },
  812. handleRefresh() {
  813. console.log('点击了重置')
  814. this.table.getdataListParm.parammaps.fname = ''
  815. this.table.getdataListParm.parammaps.fclassid = ''
  816. this.table.getdataListParm.parammaps.source = ''
  817. this.table.getdataListParm.parammaps.autozone = ''
  818. this.table.getdataListParm.parammaps.autosecond = ''
  819. this.table.getdataListParm.parammaps.allowratio = ''
  820. this.table.getdataListParm.parammaps.printgroup = ''
  821. this.table.getdataListParm.parammaps.enable = ''
  822. this.table.getdataListParm.offset = 1
  823. this.getList()
  824. },
  825. resetTemp() {
  826. this.create.temp = { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' }
  827. },
  828. // 计划类型
  829. changePlanList(item) {
  830. this.create.temp.printgroup = this.planTypeList.find(obj => obj.value === item).label
  831. },
  832. // 饲料类型
  833. changeFeedList(item) {
  834. this.create.temp.fclass = this.feedTypeList.find(obj => obj.id === item).mixname
  835. },
  836. // 跳转延时
  837. changeAutosecond(item) {
  838. this.create.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  839. },
  840. // 确认开始
  841. changeConfirmstart(item) {
  842. this.create.temp.confirmstartname = this.confirmStartList.find(obj => obj.id === item).name
  843. },
  844. changeSmallMaterial(item) {
  845. if (item !== '') {
  846. this.create.temp.smtmrname = this.smallMaterialList.find(obj => obj.id === item).tname
  847. } else {
  848. this.create.temp.smtmrname = ''
  849. }
  850. },
  851. // 新增
  852. handleCreate() {
  853. console.log('点击了新增')
  854. this.resetTemp()
  855. this.create.dialogStatus = 'create'
  856. this.create.dialogFormVisible = true
  857. },
  858. createData() {
  859. console.log('点击了新增保存')
  860. this.isokDisable = true
  861. setTimeout(() => {
  862. this.isokDisable = false
  863. }, 1000)
  864. this.$refs['temp'].validate(valid => {
  865. if (valid) {
  866. const unitweight = /^[1-9]\d*$/
  867. if (this.create.temp.unitweight !== '') {
  868. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  869. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  870. return false
  871. }
  872. }
  873. const uprice = /^\d+(\.\d{1,2})?$/
  874. if (this.create.temp.uprice !== '') {
  875. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  876. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  877. return false
  878. }
  879. }
  880. if (this.create.temp.autozone !== '') {
  881. const autozone = /^([0-9]|(1[0-9]|(20)))$/
  882. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  883. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于20的整数', duration: 2000 })
  884. return false
  885. }
  886. } else {
  887. this.create.temp.autozone = '0'
  888. }
  889. if (this.create.temp.trgaddress.length > 8) {
  890. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  891. return false
  892. }
  893. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  894. if (pattern.test(this.create.temp.fname)) {
  895. this.$message({ type: 'error', message: '饲料名称不可输入特殊字符', duration: 2000 })
  896. return false
  897. }
  898. const allowratio = /^[0-9]\d*$/
  899. if (this.create.temp.allowratio !== '') {
  900. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  901. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  902. return false
  903. }
  904. }
  905. this.isokDisable = true
  906. setTimeout(() => {
  907. this.isokDisable = false
  908. }, 1000)
  909. this.requestParam.name = 'insertFeed'
  910. this.requestParam.parammaps = this.create.temp
  911. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  912. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  913. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  914. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  915. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  916. PostDataByName(this.requestParam).then(response => {
  917. console.log('新增保存发送参数', this.requestParam)
  918. if (response.msg !== 'fail') {
  919. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  920. this.create.dialogFormVisible = false
  921. this.getList()
  922. } else {
  923. failproccess(response, this.$notify)
  924. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  925. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  926. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  927. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  928. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  929. }
  930. })
  931. }
  932. })
  933. },
  934. // 编辑
  935. handleUpdate(row) {
  936. console.log('点击了编辑', row)
  937. this.create.dialogStatus = 'update'
  938. this.create.dialogFormVisible = true
  939. row.fclassid = String(row.fclassid)
  940. row.printgroupid = String(row.printgroupid)
  941. row.autosecond = String(row.autosecond)
  942. row.confirmstart = String(row.confirmstart)
  943. row.enable = String(row.enable)
  944. this.create.temp = Object.assign({}, row)
  945. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  946. if (this.create.temp.uprice == '0.00') { this.create.temp.uprice = '' }
  947. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  948. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  949. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  950. if (this.create.temp.smtmrid == '-1') { this.create.temp.smtmrid = '' }
  951. },
  952. updateData() {
  953. console.log('点击了编辑保存')
  954. this.isokDisable = true
  955. setTimeout(() => {
  956. this.isokDisable = false
  957. }, 1000)
  958. this.$refs['temp'].validate(valid => {
  959. if (valid) {
  960. const unitweight = /^[1-9]\d*$/
  961. if (this.create.temp.unitweight !== '') {
  962. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  963. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  964. return false
  965. }
  966. }
  967. const uprice = /^\d+(\.\d{1,2})?$/
  968. if (this.create.temp.uprice !== '') {
  969. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  970. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  971. return false
  972. }
  973. }
  974. if (this.create.temp.autozone !== '') {
  975. const autozone = /^([0-9]|(1[0-9]|(20)))$/
  976. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  977. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于20的整数', duration: 2000 })
  978. return false
  979. }
  980. } else {
  981. this.create.temp.autozone = '0'
  982. }
  983. if (this.create.temp.trgaddress.length > 8) {
  984. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  985. return false
  986. }
  987. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  988. if (pattern.test(this.create.temp.fname)) {
  989. this.$message({ type: 'error', message: '饲料名称不可输入特殊字符', duration: 2000 })
  990. return false
  991. }
  992. const allowratio = /^[0-9]\d*$/
  993. if (this.create.temp.allowratio !== '') {
  994. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  995. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  996. return false
  997. }
  998. }
  999. this.isokDisable = true
  1000. setTimeout(() => {
  1001. this.isokDisable = false
  1002. }, 1000)
  1003. this.requestParam.name = 'updateFeed'
  1004. this.requestParam.parammaps = this.create.temp
  1005. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1006. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1007. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1008. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1009. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1010. PostDataByName(this.requestParam).then(response => {
  1011. console.log('新增保存发送参数', this.requestParam)
  1012. if (response.msg !== 'fail') {
  1013. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1014. this.create.dialogFormVisible = false
  1015. this.getList()
  1016. } else {
  1017. failproccess(response, this.$notify)
  1018. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1019. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1020. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1021. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1022. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1023. }
  1024. })
  1025. }
  1026. })
  1027. },
  1028. // 饲料库
  1029. handleFeedBank() {
  1030. console.log('点击了饲料库')
  1031. this.feedBank.dialogStatus = 'feedBank'
  1032. this.feedBank.dialogFormVisible = true
  1033. this.getFeedBankList()
  1034. },
  1035. getFeedBankList() {
  1036. this.feedBank.listLoading = true
  1037. GetDataByName(this.feedBank.getdataListParm).then(response => {
  1038. console.log('table数据', response.data.list)
  1039. if (response.data.list !== null) {
  1040. this.feedBank.list = response.data.list
  1041. this.feedBank.pageNum = response.data.pageNum
  1042. this.feedBank.pageSize = response.data.pageSize
  1043. this.feedBank.total = response.data.total
  1044. } else {
  1045. this.feedBank.list = []
  1046. }
  1047. setTimeout(() => {
  1048. this.feedBank.listLoading = false
  1049. }, 100)
  1050. })
  1051. },
  1052. handleFeedBankSearch() {
  1053. console.log('点击了饲料库搜索')
  1054. this.getFeedBankList()
  1055. this.feedBank.getdataListParm.offset = 1
  1056. },
  1057. handleFeedBankRefresh() {
  1058. console.log('点击了饲料库重置')
  1059. this.feedBank.getdataListParm.parammaps.fname = ''
  1060. this.feedBank.getdataListParm.parammaps.statue = ''
  1061. this.getFeedBankList()
  1062. },
  1063. // 关联
  1064. handleRelation(row) {
  1065. console.log('点击了关联')
  1066. this.relation.dialogStatus = 'relation'
  1067. this.relation.dialogFormVisible = true
  1068. this.relation.temp = Object.assign({}, row)
  1069. this.relation.getdataListParm.parammaps.fid = this.relation.temp.id
  1070. this.getRelationList()
  1071. },
  1072. getRelationList() {
  1073. this.relation.listLoading = true
  1074. GetDataByName(this.relation.getdataListParm).then(response => {
  1075. console.log('table数据', response.data.list)
  1076. if (response.data.list !== null) {
  1077. this.relation.list = response.data.list
  1078. this.relation.pageNum = response.data.pageNum
  1079. this.relation.pageSize = response.data.pageSize
  1080. this.relation.total = response.data.total
  1081. } else {
  1082. this.relation.list = []
  1083. }
  1084. setTimeout(() => {
  1085. this.relation.listLoading = false
  1086. }, 100)
  1087. })
  1088. },
  1089. handleRelationSearch() {
  1090. console.log('点击了关联搜索')
  1091. this.relation.getdataListParm.offset = 1
  1092. this.getRelationList()
  1093. },
  1094. disassociateData(row) {
  1095. console.log('点击了取消关联')
  1096. MessageBox.confirm('是否确认取消关联?', {
  1097. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1098. }).then(() => {
  1099. this.isokDisable = true
  1100. setTimeout(() => {
  1101. this.isokDisable = false
  1102. }, 1000)
  1103. this.requestParam.name = 'updateFeedrelation'
  1104. this.requestParam.parammaps = {}
  1105. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1106. this.requestParam.parammaps.fid = this.relation.temp.id
  1107. this.requestParam.parammaps.id = row.id
  1108. PostDataByName(this.requestParam).then(response => {
  1109. console.log('取消关联保存发送参数', this.requestParam)
  1110. if (response.msg !== 'fail') {
  1111. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1112. this.getRelationList()
  1113. this.getList()
  1114. } else {
  1115. failproccess(response, this.$notify)
  1116. }
  1117. })
  1118. }).catch(() => {
  1119. this.$message({ type: 'info', message: '已取消' })
  1120. })
  1121. },
  1122. relationData(row) {
  1123. console.log('点击了关联保存')
  1124. MessageBox.confirm('是否确认关联?', {
  1125. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1126. }).then(() => {
  1127. this.isokDisable = true
  1128. setTimeout(() => {
  1129. this.isokDisable = false
  1130. }, 1000)
  1131. this.requestParam.name = 'insertFeednur'
  1132. this.requestParam.parammaps = {}
  1133. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1134. this.requestParam.parammaps.fid = this.relation.temp.id
  1135. this.requestParam.parammaps.fname = this.relation.temp.fname
  1136. this.requestParam.parammaps.feedcode = this.relation.temp.feedcode
  1137. this.requestParam.parammaps.price = row.price
  1138. this.requestParam.parammaps.remark = row.remark
  1139. this.requestParam.parammaps.dry = row.dry
  1140. this.requestParam.parammaps.starch = row.starch
  1141. this.requestParam.parammaps.cp = row.cp
  1142. this.requestParam.parammaps.ca = row.ca
  1143. this.requestParam.parammaps.p = row.p
  1144. this.requestParam.parammaps.n = row.n
  1145. this.requestParam.parammaps.fat = row.fat
  1146. this.requestParam.parammaps.adf = row.adf
  1147. this.requestParam.parammaps.ndf = row.ndf
  1148. this.requestParam.parammaps.ndip = row.ndip
  1149. this.requestParam.parammaps.ash = row.ash
  1150. this.requestParam.parammaps.fpercent = row.fpercent
  1151. this.requestParam.parammaps.iscu = row.iscu
  1152. this.requestParam.parammaps.feednurid = row.id
  1153. PostDataByName(this.requestParam).then(response => {
  1154. console.log('关联保存发送参数', this.requestParam)
  1155. if (response.msg !== 'fail') {
  1156. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1157. this.getRelationList()
  1158. this.getList()
  1159. } else {
  1160. failproccess(response, this.$notify)
  1161. }
  1162. })
  1163. }).catch(() => {
  1164. this.$message({ type: 'info', message: '已取消' })
  1165. })
  1166. },
  1167. // 营养价值
  1168. handleNutritive(row) {
  1169. console.log('点击了营养价值', row)
  1170. this.nutritive.dialogStatus = 'nutritive'
  1171. this.nutritive.dialogFormVisible = true
  1172. this.nutritive.temp = Object.assign({}, row)
  1173. },
  1174. nutritiveData() {
  1175. console.log('点击了营养价值保存')
  1176. this.isokDisable = true
  1177. setTimeout(() => {
  1178. this.isokDisable = false
  1179. }, 1000)
  1180. if (this.nutritive.temp.dry == undefined) { this.$set(this.nutritive.temp, 'dry', '') }
  1181. if (this.nutritive.temp.starch == undefined) { this.$set(this.nutritive.temp, 'starch', '') }
  1182. if (this.nutritive.temp.cp == undefined) { this.$set(this.nutritive.temp, 'cp', '') }
  1183. if (this.nutritive.temp.ca == undefined) { this.$set(this.nutritive.temp, 'ca', '') }
  1184. if (this.nutritive.temp.p == undefined) { this.$set(this.nutritive.temp, 'p', '') }
  1185. if (this.nutritive.temp.n == undefined) { this.$set(this.nutritive.temp, 'n', '') }
  1186. if (this.nutritive.temp.fat == undefined) { this.$set(this.nutritive.temp, 'fat', '') }
  1187. if (this.nutritive.temp.adf == undefined) { this.$set(this.nutritive.temp, 'adf', '') }
  1188. if (this.nutritive.temp.ndf == undefined) { this.$set(this.nutritive.temp, 'ndf', '') }
  1189. if (this.nutritive.temp.ndip == undefined) { this.$set(this.nutritive.temp, 'ndip', '') }
  1190. if (this.nutritive.temp.ash == undefined) { this.$set(this.nutritive.temp, 'ash', '') }
  1191. var positiveNumber = /^\d+(\.\d{1,2})?$/
  1192. if (this.nutritive.temp.dry !== '') {
  1193. if (!positiveNumber.test(parseFloat(this.nutritive.temp.dry))) {
  1194. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1195. return false
  1196. }
  1197. }
  1198. console.log(this.nutritive.temp.starch)
  1199. if (this.nutritive.temp.starch !== '') {
  1200. if (!positiveNumber.test(parseFloat(this.nutritive.temp.starch))) {
  1201. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1202. return false
  1203. }
  1204. }
  1205. if (this.nutritive.temp.cp !== '') {
  1206. if (!positiveNumber.test(parseFloat(this.nutritive.temp.cp))) {
  1207. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1208. return false
  1209. }
  1210. }
  1211. if (this.nutritive.temp.ca !== '') {
  1212. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ca))) {
  1213. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1214. return false
  1215. }
  1216. }
  1217. if (this.nutritive.temp.p !== '') {
  1218. if (!positiveNumber.test(parseFloat(this.nutritive.temp.p))) {
  1219. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1220. return false
  1221. }
  1222. }
  1223. if (this.nutritive.temp.n !== '') {
  1224. if (!positiveNumber.test(parseFloat(this.nutritive.temp.n))) {
  1225. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1226. return false
  1227. }
  1228. }
  1229. if (this.nutritive.temp.fat !== '') {
  1230. if (!positiveNumber.test(parseFloat(this.nutritive.temp.fat))) {
  1231. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1232. return false
  1233. }
  1234. }
  1235. if (this.nutritive.temp.adf !== '') {
  1236. if (!positiveNumber.test(parseFloat(this.nutritive.temp.adf))) {
  1237. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1238. return false
  1239. }
  1240. }
  1241. if (this.nutritive.temp.ndf !== '') {
  1242. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndf))) {
  1243. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1244. return false
  1245. }
  1246. }
  1247. if (this.nutritive.temp.ndip !== '') {
  1248. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndip))) {
  1249. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1250. return false
  1251. }
  1252. }
  1253. if (this.nutritive.temp.ash !== '') {
  1254. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ash))) {
  1255. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1256. return false
  1257. }
  1258. }
  1259. this.requestParam.name = 'insertFeednur'
  1260. this.requestParam.parammaps = {}
  1261. this.requestParam.parammaps.pastureid = this.nutritive.temp.pastureid
  1262. this.requestParam.parammaps.fid = this.nutritive.temp.id
  1263. this.requestParam.parammaps.fname = this.nutritive.temp.fname
  1264. this.requestParam.parammaps.feedcode = this.nutritive.temp.feedcode
  1265. this.requestParam.parammaps.price = this.nutritive.temp.uprice
  1266. this.requestParam.parammaps.remark = this.nutritive.temp.remark
  1267. this.requestParam.parammaps.dry = this.nutritive.temp.dry
  1268. this.requestParam.parammaps.starch = this.nutritive.temp.starch
  1269. this.requestParam.parammaps.cp = this.nutritive.temp.cp
  1270. this.requestParam.parammaps.ca = this.nutritive.temp.ca
  1271. this.requestParam.parammaps.p = this.nutritive.temp.p
  1272. this.requestParam.parammaps.n = this.nutritive.temp.n
  1273. this.requestParam.parammaps.fat = this.nutritive.temp.fat
  1274. this.requestParam.parammaps.adf = this.nutritive.temp.adf
  1275. this.requestParam.parammaps.ndf = this.nutritive.temp.ndf
  1276. this.requestParam.parammaps.ndip = this.nutritive.temp.ndip
  1277. this.requestParam.parammaps.ash = this.nutritive.temp.ash
  1278. this.requestParam.parammaps.fpercent = this.nutritive.temp.fpercent
  1279. this.requestParam.parammaps.iscu = this.nutritive.temp.iscu
  1280. this.requestParam.parammaps.feednurid = '-1'
  1281. PostDataByName(this.requestParam).then(response => {
  1282. console.log('关联保存发送参数', this.requestParam)
  1283. if (response.msg !== 'fail') {
  1284. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1285. this.getList()
  1286. this.nutritive.dialogFormVisible = false
  1287. } else {
  1288. failproccess(response, this.$notify)
  1289. }
  1290. })
  1291. },
  1292. // 行内删除
  1293. handleRowDelete(row) {
  1294. console.log('点击了行内删除')
  1295. MessageBox.confirm('是否确认删除此信息?', {
  1296. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1297. }).then(() => {
  1298. this.selectList = []
  1299. this.requestParam = {}
  1300. this.requestParam.common = { 'returnmap': '0' }
  1301. this.requestParam.data = []
  1302. this.requestParam.data[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1303. 'pastureid': row.pastureid,
  1304. 'id': row.id
  1305. }}
  1306. this.requestParam.data[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1307. 'pastureid': row.pastureid,
  1308. 'id': row.id
  1309. }}
  1310. ExecDataByConfig(this.requestParam).then(response => {
  1311. console.log('删除保存发送参数', this.requestParam)
  1312. if (response.msg === 'fail') {
  1313. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1314. } else {
  1315. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1316. this.getList()
  1317. }
  1318. })
  1319. }).catch(() => {
  1320. this.$message({ type: 'info', message: '已取消删除' })
  1321. })
  1322. },
  1323. handleSelectionChange(val) {
  1324. console.log('勾选数据', val)
  1325. this.selectList = val
  1326. },
  1327. // 多项删除
  1328. handleDelete() {
  1329. console.log('点击了删除')
  1330. if (this.selectList.length == 0) {
  1331. this.$message({ type: 'error', message: '请选择饲料表信息', duration: 2000 })
  1332. } else {
  1333. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  1334. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1335. }).then(() => {
  1336. this.requestParam = {}
  1337. this.requestParam.common = { 'returnmap': '0' }
  1338. this.requestParam.data = []
  1339. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1340. this.requestParam.data[0].children = []
  1341. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1342. id: '@insertSpotList.id',
  1343. pastureid: '@insertSpotList.pastureid'
  1344. }}
  1345. this.requestParam.data[0].children[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1346. id: '@insertSpotList.id',
  1347. pastureid: '@insertSpotList.pastureid'
  1348. }}
  1349. ExecDataByConfig(this.requestParam).then(response => {
  1350. console.log('删除保存发送参数', this.requestParam)
  1351. if (response.msg === 'fail') {
  1352. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1353. } else {
  1354. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1355. this.getList()
  1356. }
  1357. })
  1358. })
  1359. }
  1360. }
  1361. }
  1362. }
  1363. </script>
  1364. <style lang="scss" scoped>
  1365. .search{margin-top:10px;}
  1366. .table{margin-top:10px;}
  1367. $width:350px;
  1368. $left:325px;
  1369. .selectInput{
  1370. position: relative;
  1371. display: inline-block;
  1372. .Input{width: $width;position: relative;}
  1373. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1374. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1375. .selectUl{
  1376. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  1377. li{
  1378. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  1379. a{float:left;width: 80px;}
  1380. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  1381. }
  1382. }
  1383. }
  1384. </style>