072a394c246729e46ed5c42bf5041486df566de8.svn-base 63 KB

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